0

I'd like to get the name of an intermediate file based on it's original attachment without relying on its post meta. As the registered image sizes e.g. thumbnail have been unregistered, the post meta is unreliable.

For example, if the attachment is named test.jpg and when it's uploaded, it typically generates the filename test-106x150.jpg

If I use wp_get_attachment_image_src( $attachment_id, 'thumbnail'), it returns an array like so:

[0] => https://domain.com/wp-content/uploads/2023/06/test.jpeg
[1] => 106
[2] => 150
[3] => 

I was hoping it would be:

[0] => https://domain.com/wp-content/uploads/2023/06/test-106x150.jpg
[1] => 106
[2] => 150
[3] => 

Is there another way?

5
  • Why wouldn't you get the second example? Have you unregistered thumbnail? Your last question suggests you might have, but you didn't mention it here. Please include all relevant information in the question. Jun 16 at 8:39
  • @JacobPeattie, yes, it's unregistered. Sorry, I should have mentioned it. I've updated the question.
    – Motivated
    Jun 16 at 8:49
  • So you want to be able to use wp_get_attachment_image_src with thumbnail even though you've unregistered it? Why? Why is it unregistered if you want to use it? Jun 16 at 8:56
  • @JacobPeattie, it's unregistered for all new files. This leaves behind a large number of orphaned files that were created that need to be deleted or removed. If the post meta is intact, I can loop through it an delete all the files. If the post meta has been overwritten, I can't find a reliable way to perform the same action.
    – Motivated
    Jun 16 at 9:07
  • Does this question help? wordpress.stackexchange.com/questions/20081/…
    – Faye
    Jun 20 at 22:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.