You did something like this to add a new thumbnail size?
Interesting… have you tried passing it a size array instead of a name?
Thread Starter
Dediux
(@dediux)
It work now!
But what’s the difference?
I can’t say without seeing your code and playing around a little bit. Sounds like the thumbnail size didn’t get set correctly for some reason, but that is a guess.
Thread Starter
Dediux
(@dediux)
In my function.php file I have these line of code:
// Enable thumbnails
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size(180, auto, true); // Normal post thumbnails
// Create custom sizes
// This is then pulled through to your theme useing the_post_thumbnail('custombig');
if ( function_exists( 'add_image_size' ) ) {
add_image_size('single-post-thumbnail', 500, auto, true); //narrow column
}
//Custom admin sizes
add_image_size('tiny-thumb', 180, auto, true);
add_image_size('normal-thumb', 500, auto, true);
function custom_wmu_image_sizes($sizes) {
unset( $sizes['thumbnail']);
unset( $sizes['medium']);
unset( $sizes['large']);
$myimgsizes = array(
"tiny-thumb" => __( "Miniatura" ),
"normal-thumb" => __( "Normale" ),
);
$newimgsizes = array_merge($sizes, $myimgsizes);
return $newimgsizes;
}
add_filter('image_size_names_choose', 'custom_wmu_image_sizes');
And in my index.php I have these:
<?php the_post_thumbnail( array(180,auto) ); ?>
To recall the function!
I think the problem was in the first two rules of my function file telling that the thumbnail size has to have 180, auto, true… It’s possible?
And how can I get a output code without the specification of height and width for my img elements? Because now the elements contain already a resized img.
I’m not sure it ‘auto’ is a valid value for the third parameter. (It might be, but I’m not sure. I’d have to look into it more.) Some of these image functions use PHP’s GD library to actually create new images. ‘auto’ may not work. Again, I’m not sure. I’d have to play with it some and try to trace where those values are used, and I don’t have that kind of time. Maybe someone else knows though.
Thread Starter
Dediux
(@dediux)
I use the value auto with the array and it work! Only the string ‘normal-thumb’ in the place of that array doesn’t work. Thank you very much for the help and for the free time you have donated to me.
Regards