_crop_image_resource

The timeline below displays how wordpress function _crop_image_resource has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.6

/**
 * Crops an image resource. Internal use only.
 *
 * @since 2.9.0
 *
 * @ignore
 * @param resource|GdImage $img Image resource or GdImage instance.
 * @param float            $x   Source point x-coordinate.
 * @param float            $y   Source point y-coordinate.
 * @param float            $w   Source width.
 * @param float            $h   Source height.
 * @return resource|GdImage (maybe) cropped image resource or GdImage instance.
 */
function _crop_image_resource($img, $x, $y, $w, $h)
{
    $dst = wp_imagecreatetruecolor($w, $h);
    if (is_gd_image($dst)) {
        if (imagecopy($dst, $img, 0, 0, $x, $y, $w, $h)) {
            imagedestroy($img);
            $img = $dst;
        }
    }
    return $img;
}

WordPress Version: 5.4

/**
 * Crops an image resource. Internal use only.
 *
 * @since 2.9.0
 *
 * @ignore
 * @param resource $img Image resource.
 * @param float    $x   Source point x-coordinate.
 * @param float    $y   Source point y-coordinate.
 * @param float    $w   Source width.
 * @param float    $h   Source height.
 * @return resource (maybe) cropped image resource.
 */
function _crop_image_resource($img, $x, $y, $w, $h)
{
    $dst = wp_imagecreatetruecolor($w, $h);
    if (is_resource($dst)) {
        if (imagecopy($dst, $img, 0, 0, $x, $y, $w, $h)) {
            imagedestroy($img);
            $img = $dst;
        }
    }
    return $img;
}

WordPress Version: 4.2

/**
 * Crops an image resource. Internal use only.
 *
 * @since 2.9.0
 *
 * @ignore
 * @param resource $img Image resource.
 * @param float    $x   Source point x-coordinate.
 * @param float    $y   Source point y-cooredinate.
 * @param float    $w   Source width.
 * @param float    $h   Source height.
 * @return resource (maybe) cropped image resource.
 */
function _crop_image_resource($img, $x, $y, $w, $h)
{
    $dst = wp_imagecreatetruecolor($w, $h);
    if (is_resource($dst)) {
        if (imagecopy($dst, $img, 0, 0, $x, $y, $w, $h)) {
            imagedestroy($img);
            $img = $dst;
        }
    }
    return $img;
}

WordPress Version: 3.7

/**
 * @TODO: Only used within image_edit_apply_changes
 *		  and receives/returns GD Resource.
 *		  Consider removal.
 *
 * @param GD_Resource $img
 * @param float $x
 * @param float $y
 * @param float $w
 * @param float $h
 * @return GD_Resource
 */
function _crop_image_resource($img, $x, $y, $w, $h)
{
    $dst = wp_imagecreatetruecolor($w, $h);
    if (is_resource($dst)) {
        if (imagecopy($dst, $img, 0, 0, $x, $y, $w, $h)) {
            imagedestroy($img);
            $img = $dst;
        }
    }
    return $img;
}