0

I want to use a couple of custom image sizes for a site that I'm developing. When I output the images I sometimes do not get the correct width size because it is mixed up with the height size. It guess it has something to do with how I declare the image sizes in the functions file.

functions.php

add_image_size( 'small', 145, 999 );
add_image_size( 'medium', 300, 999 );
add_image_size( 'large', 455, 999 );
add_image_size( 'tablet', 1024, 9999 );


$image = wp_get_attachment_image_src(get_field('custom-field'), 'medium');
print_r($image);

gives me

Array
(
    [0] => http://example.com/wp-content/uploads/2012/09/example-300x399.jpg
    [1] => 225
    [2] => 300
    [3] => 1
)

Notice the width size is no. 2 in the array, when it usually is 1. Is the output order different if the image is taller then wider? The "errors" that I get are all from vertical images.

2

The "medium" and "large" are not custom image sizes - they are already part of the core WordPress media sizes and they should be handled via the "settings" -> "media" options page in wp-admin.

Give your custom image sizes a different and more unique name (reserved are thumbnail, medium, large, full)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.