_load_image_to_edit_path

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

WordPress Version: 6.1

/**
 * Retrieves the path or URL of an attachment's attached file.
 *
 * If the attached file is not present on the local filesystem (usually due to replication plugins),
 * then the URL of the file is returned if `allow_url_fopen` is supported.
 *
 * @since 3.4.0
 * @access private
 *
 * @param int          $attachment_id Attachment ID.
 * @param string|int[] $size          Optional. Image size. Accepts any registered image size name, or an array
 *                                    of width and height values in pixels (in that order). Default 'full'.
 * @return string|false File path or URL on success, false on failure.
 */
function _load_image_to_edit_path($attachment_id, $size = 'full')
{
    $filepath = get_attached_file($attachment_id);
    if ($filepath && file_exists($filepath)) {
        if ('full' !== $size) {
            $data = image_get_intermediate_size($attachment_id, $size);
            if ($data) {
                $filepath = path_join(dirname($filepath), $data['file']);
                /**
                 * Filters the path to an attachment's file when editing the image.
                 *
                 * The filter is evaluated for all image sizes except 'full'.
                 *
                 * @since 3.1.0
                 *
                 * @param string       $path          Path to the current image.
                 * @param int          $attachment_id Attachment ID.
                 * @param string|int[] $size          Requested image size. Can be any registered image size name, or
                 *                                    an array of width and height values in pixels (in that order).
                 */
                $filepath = apply_filters('load_image_to_edit_filesystempath', $filepath, $attachment_id, $size);
            }
        }
    } elseif (function_exists('fopen') && ini_get('allow_url_fopen')) {
        /**
         * Filters the path to an attachment's URL when editing the image.
         *
         * The filter is only evaluated if the file isn't stored locally and `allow_url_fopen` is enabled on the server.
         *
         * @since 3.1.0
         *
         * @param string|false $image_url     Current image URL.
         * @param int          $attachment_id Attachment ID.
         * @param string|int[] $size          Requested image size. Can be any registered image size name, or
         *                                    an array of width and height values in pixels (in that order).
         */
        $filepath = apply_filters('load_image_to_edit_attachmenturl', wp_get_attachment_url($attachment_id), $attachment_id, $size);
    }
    /**
     * Filters the returned path or URL of the current image.
     *
     * @since 2.9.0
     *
     * @param string|false $filepath      File path or URL to current image, or false.
     * @param int          $attachment_id Attachment ID.
     * @param string|int[] $size          Requested image size. Can be any registered image size name, or
     *                                    an array of width and height values in pixels (in that order).
     */
    return apply_filters('load_image_to_edit_path', $filepath, $attachment_id, $size);
}

WordPress Version: 5.7

/**
 * Retrieve the path or URL of an attachment's attached file.
 *
 * If the attached file is not present on the local filesystem (usually due to replication plugins),
 * then the URL of the file is returned if `allow_url_fopen` is supported.
 *
 * @since 3.4.0
 * @access private
 *
 * @param int          $attachment_id Attachment ID.
 * @param string|int[] $size          Optional. Image size. Accepts any registered image size name, or an array
 *                                    of width and height values in pixels (in that order). Default 'full'.
 * @return string|false File path or URL on success, false on failure.
 */
function _load_image_to_edit_path($attachment_id, $size = 'full')
{
    $filepath = get_attached_file($attachment_id);
    if ($filepath && file_exists($filepath)) {
        if ('full' !== $size) {
            $data = image_get_intermediate_size($attachment_id, $size);
            if ($data) {
                $filepath = path_join(dirname($filepath), $data['file']);
                /**
                 * Filters the path to an attachment's file when editing the image.
                 *
                 * The filter is evaluated for all image sizes except 'full'.
                 *
                 * @since 3.1.0
                 *
                 * @param string       $path          Path to the current image.
                 * @param int          $attachment_id Attachment ID.
                 * @param string|int[] $size          Requested image size. Can be any registered image size name, or
                 *                                    an array of width and height values in pixels (in that order).
                 */
                $filepath = apply_filters('load_image_to_edit_filesystempath', $filepath, $attachment_id, $size);
            }
        }
    } elseif (function_exists('fopen') && ini_get('allow_url_fopen')) {
        /**
         * Filters the path to an attachment's URL when editing the image.
         *
         * The filter is only evaluated if the file isn't stored locally and `allow_url_fopen` is enabled on the server.
         *
         * @since 3.1.0
         *
         * @param string|false $image_url     Current image URL.
         * @param int          $attachment_id Attachment ID.
         * @param string|int[] $size          Requested image size. Can be any registered image size name, or
         *                                    an array of width and height values in pixels (in that order).
         */
        $filepath = apply_filters('load_image_to_edit_attachmenturl', wp_get_attachment_url($attachment_id), $attachment_id, $size);
    }
    /**
     * Filters the returned path or URL of the current image.
     *
     * @since 2.9.0
     *
     * @param string|false $filepath      File path or URL to current image, or false.
     * @param int          $attachment_id Attachment ID.
     * @param string|int[] $size          Requested image size. Can be any registered image size name, or
     *                                    an array of width and height values in pixels (in that order).
     */
    return apply_filters('load_image_to_edit_path', $filepath, $attachment_id, $size);
}

WordPress Version: 5.6

/**
 * Retrieve the path or URL of an attachment's attached file.
 *
 * If the attached file is not present on the local filesystem (usually due to replication plugins),
 * then the URL of the file is returned if `allow_url_fopen` is supported.
 *
 * @since 3.4.0
 * @access private
 *
 * @param int          $attachment_id Attachment ID.
 * @param string|int[] $size          Optional. Image size. Accepts any registered image size name, or an array
 *                                    of width and height values in pixels (in that order). Default 'full'.
 * @return string|false File path or URL on success, false on failure.
 */
function _load_image_to_edit_path($attachment_id, $size = 'full')
{
    $filepath = get_attached_file($attachment_id);
    if ($filepath && file_exists($filepath)) {
        if ('full' !== $size) {
            $data = image_get_intermediate_size($attachment_id, $size);
            if ($data) {
                $filepath = path_join(dirname($filepath), $data['file']);
                /**
                 * Filters the path to an attachment's file when editing the image.
                 *
                 * The filter is evaluated for all image sizes except 'full'.
                 *
                 * @since 3.1.0
                 *
                 * @param string       $path          Path to the current image.
                 * @param int          $attachment_id Attachment ID.
                 * @param string|int[] $size          Requested image size. Can be any registered image size name, or
                 *                                    an array of width and height values in pixels (in that order).
                 */
                $filepath = apply_filters('load_image_to_edit_filesystempath', $filepath, $attachment_id, $size);
            }
        }
    } elseif (function_exists('fopen') && ini_get('allow_url_fopen')) {
        /**
         * Filters the path to an attachment's URL when editing the image.
         *
         * The filter is only evaluated if the file isn't stored locally and `allow_url_fopen` is enabled on the server.
         *
         * @since 3.1.0
         *
         * @param string       $image_url     Current image URL.
         * @param int          $attachment_id Attachment ID.
         * @param string|int[] $size          Requested image size. Can be any registered image size name, or
         *                                    an array of width and height values in pixels (in that order).
         */
        $filepath = apply_filters('load_image_to_edit_attachmenturl', wp_get_attachment_url($attachment_id), $attachment_id, $size);
    }
    /**
     * Filters the returned path or URL of the current image.
     *
     * @since 2.9.0
     *
     * @param string|bool  $filepath      File path or URL to current image, or false.
     * @param int          $attachment_id Attachment ID.
     * @param string|int[] $size          Requested image size. Can be any registered image size name, or
     *                                    an array of width and height values in pixels (in that order).
     */
    return apply_filters('load_image_to_edit_path', $filepath, $attachment_id, $size);
}

WordPress Version: 5.3

/**
 * Retrieve the path or url of an attachment's attached file.
 *
 * If the attached file is not present on the local filesystem (usually due to replication plugins),
 * then the url of the file is returned if url fopen is supported.
 *
 * @since 3.4.0
 * @access private
 *
 * @param string $attachment_id Attachment ID.
 * @param string $size Optional. Image size, defaults to 'full'.
 * @return string|false File path or url on success, false on failure.
 */
function _load_image_to_edit_path($attachment_id, $size = 'full')
{
    $filepath = get_attached_file($attachment_id);
    if ($filepath && file_exists($filepath)) {
        if ('full' !== $size) {
            $data = image_get_intermediate_size($attachment_id, $size);
            if ($data) {
                $filepath = path_join(dirname($filepath), $data['file']);
                /**
                 * Filters the path to the current image.
                 *
                 * The filter is evaluated for all image sizes except 'full'.
                 *
                 * @since 3.1.0
                 *
                 * @param string $path          Path to the current image.
                 * @param string $attachment_id Attachment ID.
                 * @param string $size          Size of the image.
                 */
                $filepath = apply_filters('load_image_to_edit_filesystempath', $filepath, $attachment_id, $size);
            }
        }
    } elseif (function_exists('fopen') && ini_get('allow_url_fopen')) {
        /**
         * Filters the image URL if not in the local filesystem.
         *
         * The filter is only evaluated if fopen is enabled on the server.
         *
         * @since 3.1.0
         *
         * @param string $image_url     Current image URL.
         * @param string $attachment_id Attachment ID.
         * @param string $size          Size of the image.
         */
        $filepath = apply_filters('load_image_to_edit_attachmenturl', wp_get_attachment_url($attachment_id), $attachment_id, $size);
    }
    /**
     * Filters the returned path or URL of the current image.
     *
     * @since 2.9.0
     *
     * @param string|bool $filepath      File path or URL to current image, or false.
     * @param string      $attachment_id Attachment ID.
     * @param string      $size          Size of the image.
     */
    return apply_filters('load_image_to_edit_path', $filepath, $attachment_id, $size);
}

WordPress Version: 4.7

/**
 * Retrieve the path or url of an attachment's attached file.
 *
 * If the attached file is not present on the local filesystem (usually due to replication plugins),
 * then the url of the file is returned if url fopen is supported.
 *
 * @since 3.4.0
 * @access private
 *
 * @param string $attachment_id Attachment ID.
 * @param string $size Optional. Image size, defaults to 'full'.
 * @return string|false File path or url on success, false on failure.
 */
function _load_image_to_edit_path($attachment_id, $size = 'full')
{
    $filepath = get_attached_file($attachment_id);
    if ($filepath && file_exists($filepath)) {
        if ('full' != $size && $data = image_get_intermediate_size($attachment_id, $size)) {
            /**
             * Filters the path to the current image.
             *
             * The filter is evaluated for all image sizes except 'full'.
             *
             * @since 3.1.0
             *
             * @param string $path          Path to the current image.
             * @param string $attachment_id Attachment ID.
             * @param string $size          Size of the image.
             */
            $filepath = apply_filters('load_image_to_edit_filesystempath', path_join(dirname($filepath), $data['file']), $attachment_id, $size);
        }
    } elseif (function_exists('fopen') && true == ini_get('allow_url_fopen')) {
        /**
         * Filters the image URL if not in the local filesystem.
         *
         * The filter is only evaluated if fopen is enabled on the server.
         *
         * @since 3.1.0
         *
         * @param string $image_url     Current image URL.
         * @param string $attachment_id Attachment ID.
         * @param string $size          Size of the image.
         */
        $filepath = apply_filters('load_image_to_edit_attachmenturl', wp_get_attachment_url($attachment_id), $attachment_id, $size);
    }
    /**
     * Filters the returned path or URL of the current image.
     *
     * @since 2.9.0
     *
     * @param string|bool $filepath      File path or URL to current image, or false.
     * @param string      $attachment_id Attachment ID.
     * @param string      $size          Size of the image.
     */
    return apply_filters('load_image_to_edit_path', $filepath, $attachment_id, $size);
}

WordPress Version: 4.6

/**
 * Retrieve the path or url of an attachment's attached file.
 *
 * If the attached file is not present on the local filesystem (usually due to replication plugins),
 * then the url of the file is returned if url fopen is supported.
 *
 * @since 3.4.0
 * @access private
 *
 * @param string $attachment_id Attachment ID.
 * @param string $size Optional. Image size, defaults to 'full'.
 * @return string|false File path or url on success, false on failure.
 */
function _load_image_to_edit_path($attachment_id, $size = 'full')
{
    $filepath = get_attached_file($attachment_id);
    if ($filepath && file_exists($filepath)) {
        if ('full' != $size && $data = image_get_intermediate_size($attachment_id, $size)) {
            /**
             * Filters the path to the current image.
             *
             * The filter is evaluated for all image sizes except 'full'.
             *
             * @since 3.1.0
             *
             * @param string $path          Path to the current image.
             * @param string $attachment_id Attachment ID.
             * @param string $size          Size of the image.
             */
            $filepath = apply_filters('load_image_to_edit_filesystempath', path_join(dirname($filepath), $data['file']), $attachment_id, $size);
        }
    } elseif (function_exists('fopen') && function_exists('ini_get') && true == ini_get('allow_url_fopen')) {
        /**
         * Filters the image URL if not in the local filesystem.
         *
         * The filter is only evaluated if fopen is enabled on the server.
         *
         * @since 3.1.0
         *
         * @param string $image_url     Current image URL.
         * @param string $attachment_id Attachment ID.
         * @param string $size          Size of the image.
         */
        $filepath = apply_filters('load_image_to_edit_attachmenturl', wp_get_attachment_url($attachment_id), $attachment_id, $size);
    }
    /**
     * Filters the returned path or URL of the current image.
     *
     * @since 2.9.0
     *
     * @param string|bool $filepath      File path or URL to current image, or false.
     * @param string      $attachment_id Attachment ID.
     * @param string      $size          Size of the image.
     */
    return apply_filters('load_image_to_edit_path', $filepath, $attachment_id, $size);
}

WordPress Version: 3.9

/**
 * Retrieve the path or url of an attachment's attached file.
 *
 * If the attached file is not present on the local filesystem (usually due to replication plugins),
 * then the url of the file is returned if url fopen is supported.
 *
 * @since 3.4.0
 * @access private
 *
 * @param string $attachment_id Attachment ID.
 * @param string $size Optional. Image size, defaults to 'full'.
 * @return string|false File path or url on success, false on failure.
 */
function _load_image_to_edit_path($attachment_id, $size = 'full')
{
    $filepath = get_attached_file($attachment_id);
    if ($filepath && file_exists($filepath)) {
        if ('full' != $size && $data = image_get_intermediate_size($attachment_id, $size)) {
            /**
             * Filter the path to the current image.
             *
             * The filter is evaluated for all image sizes except 'full'.
             *
             * @since 3.1.0
             *
             * @param string $path          Path to the current image.
             * @param string $attachment_id Attachment ID.
             * @param string $size          Size of the image.
             */
            $filepath = apply_filters('load_image_to_edit_filesystempath', path_join(dirname($filepath), $data['file']), $attachment_id, $size);
        }
    } elseif (function_exists('fopen') && function_exists('ini_get') && true == ini_get('allow_url_fopen')) {
        /**
         * Filter the image URL if not in the local filesystem.
         *
         * The filter is only evaluated if fopen is enabled on the server.
         *
         * @since 3.1.0
         *
         * @param string $image_url     Current image URL.
         * @param string $attachment_id Attachment ID.
         * @param string $size          Size of the image.
         */
        $filepath = apply_filters('load_image_to_edit_attachmenturl', wp_get_attachment_url($attachment_id), $attachment_id, $size);
    }
    /**
     * Filter the returned path or URL of the current image.
     *
     * @since 2.9.0
     *
     * @param string|bool $filepath      File path or URL to current image, or false.
     * @param string      $attachment_id Attachment ID.
     * @param string      $size          Size of the image.
     */
    return apply_filters('load_image_to_edit_path', $filepath, $attachment_id, $size);
}

WordPress Version: 3.7

/**
 * Retrieve the path or url of an attachment's attached file.
 *
 * If the attached file is not present on the local filesystem (usually due to replication plugins),
 * then the url of the file is returned if url fopen is supported.
 *
 * @since 3.4.0
 * @access private
 *
 * @param string $attachment_id Attachment ID.
 * @param string $size Optional. Image size, defaults to 'full'.
 * @return string|false File path or url on success, false on failure.
 */
function _load_image_to_edit_path($attachment_id, $size = 'full')
{
    $filepath = get_attached_file($attachment_id);
    if ($filepath && file_exists($filepath)) {
        if ('full' != $size && $data = image_get_intermediate_size($attachment_id, $size)) {
            $filepath = apply_filters('load_image_to_edit_filesystempath', path_join(dirname($filepath), $data['file']), $attachment_id, $size);
        }
    } elseif (function_exists('fopen') && function_exists('ini_get') && true == ini_get('allow_url_fopen')) {
        $filepath = apply_filters('load_image_to_edit_attachmenturl', wp_get_attachment_url($attachment_id), $attachment_id, $size);
    }
    return apply_filters('load_image_to_edit_path', $filepath, $attachment_id, $size);
}