wp_get_original_image_path()
Retrieves the path to an uploaded image file.
Similar to get_attached_file() some images may have been processed after uploading to make them suitable for web use. In this case the attached "full" size file is usually replaced with a scaled down version of the original image. This function always returns the path to the originally uploaded image file.
1 time — 0.0014172 sec (very slow) | 50000 times — 1.04 sec (fast)
Hooks from the function
Return
String|false
. Path to the original image file or false if the attachment is not an image.
Usage
wp_get_original_image_path( $attachment_id, $unfiltered );
- $attachment_id(int) (required)
- Attachment ID.
- $unfiltered(true|false)
- Passed through to get_attached_file().
Default: false
Examples
#1 Display the path to the picture
$attach_path = wp_get_original_image_path( 516 ); if ( $attach_path ) { echo $attach_path; } else { echo 'This file is not an image or the specified image does not exist'; }
Changelog
Since 5.3.0 | Introduced. |
Since 5.4.0 | Added the $unfiltered parameter. |