I found this great topic but am not allowed to comment due to my rep……
So I found myself forced to open this new topic (am I right?)
It states this code in order to scale up my images, it works perfectly!
function image_crop_dimensions($default, $orig_w, $orig_h, $new_w, $new_h, $crop){
if ( !$crop ) return null; // let the wordpress default function handle this
$aspect_ratio = $orig_w / $orig_h;
$size_ratio = max($new_w / $orig_w, $new_h / $orig_h);
$crop_w = round($new_w / $size_ratio);
$crop_h = round($new_h / $size_ratio);
$s_x = floor( ($orig_w - $crop_w) / 2 );
$s_y = floor( ($orig_h - $crop_h) / 2 );
return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
}
add_filter('image_resize_dimensions', 'image_crop_dimensions', 10, 6);
however It does not work for image sizes defined like this:
add_image_size( '800', 800 );
of course, cause there’s no $new_h
right?
how can I fix this function to work on add_image_size( '800', 800 );
images?
Thanks!
EDIT
Changed my add_image_size( '800', 800 );
to add_image_size( '800', 800, 800 );
and it still does not work.
this is because crop
is set to false, if I do this, add_image_size( '800', 800, 800, true );
it works,
but I don’t want the crop!
Thanks guys
The function add_image_size need numbers, in your code the first parameter is a String.
so if you replace ‘800’ with 800, could work.