Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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)

share|improve this answer
    
That did it, thanks! –  Staffan Estberg Sep 11 '12 at 8:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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