_flip_image_resource

The timeline below displays how wordpress function _flip_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

/**
 * Flips an image resource. Internal use only.
 *
 * @since 2.9.0
 * @deprecated 3.5.0 Use WP_Image_Editor::flip()
 * @see WP_Image_Editor::flip()
 *
 * @ignore
 * @param resource|GdImage $img  Image resource or GdImage instance.
 * @param bool             $horz Whether to flip horizontally.
 * @param bool             $vert Whether to flip vertically.
 * @return resource|GdImage (maybe) flipped image resource or GdImage instance.
 */
function _flip_image_resource($img, $horz, $vert)
{
    _deprecated_function(__FUNCTION__, '3.5.0', 'WP_Image_Editor::flip()');
    $w = imagesx($img);
    $h = imagesy($img);
    $dst = wp_imagecreatetruecolor($w, $h);
    if (is_gd_image($dst)) {
        $sx = $vert ? $w - 1 : 0;
        $sy = $horz ? $h - 1 : 0;
        $sw = $vert ? -$w : $w;
        $sh = $horz ? -$h : $h;
        if (imagecopyresampled($dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh)) {
            imagedestroy($img);
            $img = $dst;
        }
    }
    return $img;
}

WordPress Version: 4.9

/**
 * Flips an image resource. Internal use only.
 *
 * @since 2.9.0
 * @deprecated 3.5.0 Use WP_Image_Editor::flip()
 * @see WP_Image_Editor::flip()
 *
 * @ignore
 * @param resource $img  Image resource.
 * @param bool     $horz Whether to flip horizontally.
 * @param bool     $vert Whether to flip vertically.
 * @return resource (maybe) flipped image resource.
 */
function _flip_image_resource($img, $horz, $vert)
{
    _deprecated_function(__FUNCTION__, '3.5.0', 'WP_Image_Editor::flip()');
    $w = imagesx($img);
    $h = imagesy($img);
    $dst = wp_imagecreatetruecolor($w, $h);
    if (is_resource($dst)) {
        $sx = $vert ? $w - 1 : 0;
        $sy = $horz ? $h - 1 : 0;
        $sw = $vert ? -$w : $w;
        $sh = $horz ? -$h : $h;
        if (imagecopyresampled($dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh)) {
            imagedestroy($img);
            $img = $dst;
        }
    }
    return $img;
}

WordPress Version: 4.7

/**
 * Flips an image resource. Internal use only.
 *
 * @since 2.9.0
 *
 * @ignore
 * @param resource $img  Image resource.
 * @param bool     $horz Whether to flip horizontally.
 * @param bool     $vert Whether to flip vertically.
 * @return resource (maybe) flipped image resource.
 */
function _flip_image_resource($img, $horz, $vert)
{
    _deprecated_function(__FUNCTION__, '3.5.0', 'WP_Image_Editor::flip()');
    $w = imagesx($img);
    $h = imagesy($img);
    $dst = wp_imagecreatetruecolor($w, $h);
    if (is_resource($dst)) {
        $sx = $vert ? $w - 1 : 0;
        $sy = $horz ? $h - 1 : 0;
        $sw = $vert ? -$w : $w;
        $sh = $horz ? -$h : $h;
        if (imagecopyresampled($dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh)) {
            imagedestroy($img);
            $img = $dst;
        }
    }
    return $img;
}

WordPress Version: 4.6

/**
 * Flips an image resource. Internal use only.
 *
 * @since 2.9.0
 *
 * @ignore
 * @param resource $img  Image resource.
 * @param bool     $horz Whether to flip horizontally.
 * @param bool     $vert Whether to flip vertically.
 * @return resource (maybe) flipped image resource.
 */
function _flip_image_resource($img, $horz, $vert)
{
    _deprecated_function(__FUNCTION__, '3.5.0', __('Use WP_Image_Editor::flip'));
    $w = imagesx($img);
    $h = imagesy($img);
    $dst = wp_imagecreatetruecolor($w, $h);
    if (is_resource($dst)) {
        $sx = $vert ? $w - 1 : 0;
        $sy = $horz ? $h - 1 : 0;
        $sw = $vert ? -$w : $w;
        $sh = $horz ? -$h : $h;
        if (imagecopyresampled($dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh)) {
            imagedestroy($img);
            $img = $dst;
        }
    }
    return $img;
}

WordPress Version: 4.2

/**
 * Flips an image resource. Internal use only.
 *
 * @since 2.9.0
 *
 * @ignore
 * @param resource $img  Image resource.
 * @param bool     $horz Whether to flip horizontally.
 * @param bool     $vert Whether to flip vertically.
 * @return resource (maybe) flipped image resource.
 */
function _flip_image_resource($img, $horz, $vert)
{
    _deprecated_function(__FUNCTION__, '3.5', __('Use WP_Image_Editor::flip'));
    $w = imagesx($img);
    $h = imagesy($img);
    $dst = wp_imagecreatetruecolor($w, $h);
    if (is_resource($dst)) {
        $sx = $vert ? $w - 1 : 0;
        $sy = $horz ? $h - 1 : 0;
        $sw = $vert ? -$w : $w;
        $sh = $horz ? -$h : $h;
        if (imagecopyresampled($dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh)) {
            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 boolean $horz
 * @param boolean $vert
 * @return GD_Resource
 */
function _flip_image_resource($img, $horz, $vert)
{
    _deprecated_function(__FUNCTION__, '3.5', __('Use WP_Image_Editor::flip'));
    $w = imagesx($img);
    $h = imagesy($img);
    $dst = wp_imagecreatetruecolor($w, $h);
    if (is_resource($dst)) {
        $sx = $vert ? $w - 1 : 0;
        $sy = $horz ? $h - 1 : 0;
        $sw = $vert ? -$w : $w;
        $sh = $horz ? -$h : $h;
        if (imagecopyresampled($dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh)) {
            imagedestroy($img);
            $img = $dst;
        }
    }
    return $img;
}