[wp-trac] [WordPress Trac] #48421: Add $unfiltered param to wp_get_original_image_path() and wp_get_original_image_url() functions
WordPress Trac
noreply at wordpress.org
Tue Feb 11 13:30:47 UTC 2020
#48421: Add $unfiltered param to wp_get_original_image_path() and
wp_get_original_image_url() functions
-------------------------------+-----------------------------
Reporter: ianmjones | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Media | Version: 5.3
Severity: normal | Resolution:
Keywords: reporter-feedback | Focuses:
-------------------------------+-----------------------------
Comment (by ianmjones):
Replying to [comment:3 joemcgill]:
> For `wp_get_original_image_path()` it might make sense to pass `true` as
the second parameter to the `get_attached_file()` call when that is used
as a fallback for the image path. Like @azaozz, I don't see a great way of
bypassing filters when calling `wp_get_original_image_url()` though.
>
> @ianmjones can you share a use case where this is currently tripping you
up?
Because our plugin offloads a Media Library item to a storage provider's
bucket and then optionally removes the local files, any call to
`wp_get_original_image_path()` will ultimately be filtered to return the
StreamWrapper URL instead of local path if the file does not exist
locally. If the file does exist locally then WP Offload Media returns that
unfiltered version.
Under certain scenarios you need the unfiltered local path (and unencoded
file name) no matter what, e.g. you're preparing to copy the file back to
its local path, or a backup or image processing plugin wants to work with
local versions only and will check the path returned anyway.
For `get_attached_file()` we have the `$unfiltered` param, but if we need
to get the original image's local path and name, which may or may not be
different from the current full size image in various ways, we have no
ability to let WordPress tell us what it should be.
The request for similar unfiltered URL functions is for consistency,
scenarios where the "canonical" URL is required for adding to headers etc,
and for quick comparison of URLs in content (WP Offload Media tries to
ensure WordPress saves the local URL in database content and filters it
where necessary).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48421#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list