[wp-trac] [WordPress Trac] #18947: get_intermediate_image_sizes() should also contain width/height/crop values as sub array
WordPress Trac
noreply at wordpress.org
Thu Jul 10 09:09:01 UTC 2014
#18947: get_intermediate_image_sizes() should also contain width/height/crop values
as sub array
-------------------------+-----------------------------
Reporter: F J Kaiser | Owner:
Type: enhancement | Status: assigned
Priority: normal | Milestone: Future Release
Component: Media | Version: 3.2.1
Severity: normal | Resolution:
Keywords: needs-patch | Focuses:
-------------------------+-----------------------------
Comment (by F J Kaiser):
Replying to [comment:16 krogsgard]:
> As shown in 18947_5_2.patch, `get_image_sizes_data()` won't return
anything for custom image sizes, since that data isn't in the database and
the global that stores that data isn't in the `foreach` loop, though the
global is getting called from `get_intermediate_image_sizes()` anyway.
That's the point. Why would we try to return something that isn't there.
And the default assumption has to be the most minimal setup. As soon as
this is taken into account and not failing, we can build upon it.
> If you do something like the following, you can get single image size
data without calling the global, as long as it's a standard size.
>
> {{{
> function get_image_size_data( $size = 'thumbnail' ) {
> // (...) shortened internals
> if ( in_array( $size, $default_image_sizes ) ) {
> $result[ $size ]['crop'] = get_option( "{$size}_crop" );
> } else {
> $result = $_wp_additional_image_sizes[ $size ];
> }
>
> return $result;
> }
> }}}
This would for default sizes return an {{{Array}}} and a {{{string}}} for
custom image sizes.
> It also avoids calling `get_intermediate_image_sizes()`. That function
is a nightmare of a name considering it gets **all** image sizes, but says
it only gets intermediate.
The {{{get_image_sizes_data()}}} ({{{18947_5_2.patch}}}) patch removes
that necessity be wrapping it up. I want to stay back from introducing
doubled functionality just to remove a function name. You would have to
move {{{get_intermediate_image_sizes()}}} to {{{deprecated.php}}} (and
inform users to use the new function) just for the sake of renaming it.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/18947#comment:19>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list