Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#39583 closed feature request (duplicate)

Add a new function for images: "get_image_size()"

Reported by: alexvorn2's profile alexvorn2 Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.8
Component: Media Keywords:
Focuses: template Cc:

Description

We have add_image_size() function but we don't have get_image_size()
Why we need it? So we can know what size in pixels for the specific fetured image settings.

As we know when we can add a featured images settings with specific size in a new theme, for example:
add_image_size( 'featured-small', 800 );
(so we set 800 pixels for a featured-small image)

But when we want later to find this size we can't so we need a new function
get_image_size( 'featured-small' ) that will return the size of 800 so we can know that to do next.

Change History (5)

#1 @SergeyBiryukov
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi @alexvorn2, thanks for the ticket!

#18947 already has a patch that introduces get_image_size().

#2 @alexvorn2
8 years ago

Like this:

<?php
function get_image_size( $name = '' ) {
        global $_wp_additional_image_sizes;

        if ( isset( $_wp_additional_image_sizes[$name] ) ) {
                return $_wp_additional_image_sizes[$name];
        } else {
                return false;
        }
}

#3 follow-up: @alexvorn2
8 years ago

NO, no, my ticket is a new function, not improvement for the old one.

#4 in reply to: ↑ 3 ; follow-up: @SergeyBiryukov
8 years ago

Replying to alexvorn2:

NO, no, my ticket is a new function, not improvement for the old one.

Have you seen 18947_6_2.patch:ticket:18947? Wouldn't it work for your case?

#5 in reply to: ↑ 4 @alexvorn2
8 years ago

Oh, OK.

Note: See TracTickets for help on using tickets.