wp_get_original_image_url()
Retrieve the URL to an original attachment image.
Similar to wp_get_attachment_url() some images may have been processed after uploading. In this case this function returns the URL to the originally uploaded image file.
Hooks from the function
Return
String|false
. Attachment image URL, false on error or if the attachment is not an image.
Usage
wp_get_original_image_url( $attachment_id );
- $attachment_id(int) (required)
- Attachment post ID.
Examples
#1 Getting the original size
Let's say we uploaded a big picture of 8000x6000px to the site. And now when we try to get a big picture we get a URL to a big picture (2056x1650px) but not the original picture, but we want the original one. To do that we use this function.
$attach_id = 200; wp_get_attachment_url( $attach_id ); // http://example.com/wp-content/uploads/2020/03/jpg-big-image-scaled.jpeg wp_get_original_image_url( $attach_id ); // http://example.com/wp-content/uploads/2020/03/jpg-big-image.jpeg
Changelog
Since 5.3.0 | Introduced. |