Is there any filter available to set the naming convention of those auto generated thumbnails?
Something like this:
- thumbnail_150x150.jpg -> thumbnail-s.jpg
- thumbnail_300x300.jpg -> thumbnail-m.jpg
- thumbnail_600x600.jpg -> thumbnail-l.jpg
Is there any filter available to set the naming convention of those auto generated thumbnails?
Something like this:
You must be logged in to post a comment.
Seems that the answer is no…
I’ve followed the core functions and found a dead-end. And found this post ( How can I make add_image_size() crop from the top? ) where Rarst says:
But, following the lead of the other answer (from bradt) and the code he published ( Image Crop Position in WordPress ), I think I got it 🙂
In the function
bt_generate_attachment_metadata
, I’ve just modified the call tobt_image_make_intermediate_size
including the last parameter$size
And modified the beggining of the function
bt_image_make_intermediate_size
as follows:$size
parameter to the functionnull
value to$suffix
, aswitch
to our new suffixes Here, a copy of the full code with my mods, just for reference.And the diff from the original.
[2021]
I reviewed the code to fix the following warnings, (h/t @meek2100): two WP functions were deprecated and there’s a PHP 8 notice about named parameters.
Gist with the changes annotated on code.
You could use the filter image_make_intermediate_size, but you would have to figure out what name you want to change the intermediate file to, according to the $filename you get (and then rename the file, because at this point it already has been generated).
I only generate an intermediate size image for the “thumbnail”, so it is as simple as this: