[wp-trac] [WordPress Trac] #24759: wp_generate_attachment_metadata not generating custom image sizes
WordPress Trac
noreply at wordpress.org
Mon Jul 15 13:58:32 UTC 2013
#24759: wp_generate_attachment_metadata not generating custom image sizes
--------------------------+-----------------------------
Reporter: ryanengland | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 3.5.2
Severity: normal | Keywords:
--------------------------+-----------------------------
I'm having a little trouble resizing some images to the correct size
according to a custom image size.
I have been troubleshooting this for a while and trying to work out what
is going on, and it would seem that this is an issue with the
wp_generate_attachment_metadata function that I've not come across before.
My code to set up the 6 custom image sizes in functions.php is as follows:
{{{
add_action('after_setup_theme', 'theme_setup');
function theme_setup() {
add_image_size( 'TeamMemberImage', '978', '297', true);
add_image_size( '464by260', '464', '260', true);
add_image_size( 'AwardLogo', '180', '80', true);
add_image_size( 'Small', '222', '125');
add_image_size( 'HomePageRotator', '1420', '665');
add_image_size( 'Col33Image', '300', '170');
}
}}}
I'm using the following code:
{{{
$metadata = wp_generate_attachment_metadata( $image->ID, $fullsizepath );
print_r($metadata);
}}}
For newer images uploaded within the last week or so, the output of the
above code is as below:
{{{
Array
(
[width] => 464
[height] => 261
[file] => 2013/05/464x261_images-Ade.jpg
[sizes] => Array
(
[thumbnail] => Array
(
[file] => 464x261_images-Ade-150x150.jpg
[width] => 150
[height] => 150
[mime-type] => image/jpeg
)
[464by260] => Array
(
[file] => 464x261_images-Ade-464x260.jpg
[width] => 464
[height] => 260
[mime-type] => image/jpeg
)
[AwardLogo] => Array
(
[file] => 464x261_images-Ade-180x80.jpg
[width] => 180
[height] => 80
[mime-type] => image/jpeg
)
[Small] => Array
(
[file] => 464x261_images-Ade-222x125.jpg
[width] => 222
[height] => 125
[mime-type] => image/jpeg
)
[Col33Image] => Array
(
[file] => 464x261_images-Ade-300x168.jpg
[width] => 300
[height] => 168
[mime-type] => image/jpeg
)
)
[image_meta] => Array
(
[aperture] => 0
[credit] =>
[camera] =>
[caption] =>
[created_timestamp] => 0
[copyright] =>
[focal_length] => 0
[iso] => 0
[shutter_speed] => 0
[title] =>
)
)
}}}
So this is correct. It generates some, but not all, custom image sizes and
creates URLs for each of these. However, for older images (possibly
uploaded prior to adding the custom image sizes), the output of the above
code is as follows:
{{{
Array
(
[width] => 978
[height] => 300
[file] => 2013/03/wk_cover_mizunoseiei1.jpg
[sizes] => Array
(
[464by260] => Array
(
[file] => wk_cover_mizunoseiei1-464x260.jpg
[width] => 464
[height] => 260
[mime-type] => image/jpeg
)
)
[image_meta] => Array
(
[aperture] => 0
[credit] =>
[camera] =>
[caption] =>
[created_timestamp] => 0
[copyright] =>
[focal_length] => 0
[iso] => 0
[shutter_speed] => 0
[title] =>
)
)
}}}
So it seems to only generate the one of the custom image sizes (464by260)
and none of the others.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/24759>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list