[wp-trac] [WordPress Trac] #40370: add_image_sizes does not create the "crop position" versions of the image
WordPress Trac
noreply at wordpress.org
Sun Jan 24 00:01:55 UTC 2021
#40370: add_image_sizes does not create the "crop position" versions of the image
-------------------------------------------------+-------------------------
Reporter: piejesus | Owner: (none)
Type: enhancement | Status: reopened
Priority: normal | Milestone: Future
| Release
Component: Media | Version: 2.9
Severity: normal | Resolution:
Keywords: needs-unit-tests good-first-bug | Focuses:
has-patch 2nd-opinion |
-------------------------------------------------+-------------------------
Comment (by davidbawiec):
Hi all,
Happy new year! Checking in on this. This is still (sadly) a valid bug in
WordPress 5.6. In fact,
[https://wordpress.stackexchange.com/questions/188087/thumbnails-of-same-
size-with-different-crop this thread] on StackExchange from 2015 suggests
it's been a bug for 6 years now, so it would be great to get this one
squashed and out the door. :)
As previously suggested, adding either a hash or the size name to the
filename would definitely solve this issue.
As a temporary fix, a potential is also to add a filter to the
get_suffix() method in wp-includes/class-wp-image-editor.php:
ORIGINAL CODE:
{{{
public function get_suffix() {
if ( ! $this->get_size() ) {
return false;
}
return "{$this->size['width']}x{$this->size['height']}";
}
}}}
MODIFIED CODE:
{{{
public function get_suffix() {
if ( ! $this->get_size() ) {
return false;
}
$format =
"{$this->size['width']}x{$this->size['height']}";
return apply_filters('get_image_filename_suffix', $format
);
}
}}}
The filter could allow devs to override the naming format for image
thumbnails. Of course, having the naming convention altered to fix this
altogether would be fantastic and a preferred solution to this patch.
Either way would love to hear about any progress that has been made on
this bug. @azaozz it seems like you were last involved in some
conversations on this?
Cheers!
David
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40370#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list