Home / APIs / _load_image_to_edit_path() – Retrieve the path or url of an attachment’s attached file.

You appear to be a bot. Output may be restricted

Description

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.

Usage

$string|false = _load_image_to_edit_path( $attachment_id, $size );

Parameters

$attachment_id
( string ) required – Attachment ID.
$size
( string ) optional default: full – Optional. Image size, defaults to 'full'.

Returns

string|false File path or url on success, false on failure.

Source

File name: wordpress/wp-admin/includes/image.php
Lines: 1 to 44 of 44

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 );
}
 

 View on GitHub View on Trac

Published: 12th March 2017 | Last updated: 12th March 2017

Information

Function name: _load_image_to_edit_path
Plugin ref: WordPress
Version: 5.0.3
Sourcefile: wp-admin/includes/image.php
File ref: wp-admin/includes/image.php
API type: private
Deprecated?: No
API Letters: _,E,I,L,T

  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Files
  • Hooks
  • Classes
  • Sites
  • Sitemap
  • Blog
WooCommerce a2z WooCommerce a2z
WooCommerce

Site:  woocommerce.wp-a2z.org
© Copyright WooCommerce a2z 2014-2019. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins