I am trying to crop a 1000 x 648 image to 400 x 400. I use this code in functions.php
add_theme_support( 'post-thumbnails' );
add_image_size('shop-size', 400, 400, array(center,center) );
add_image_size('shop-size2', 401, 400, true );
then i go to the regenerate plugin and run it. While I run it I open up wp-content uploads to check out what's going on.
I watch as it creates a 400x259 image that is scaled. The regenerate plugin even says it is going to do a 400x400 cropped to fit for shop-size, and then proceeds not to.
I checked if gd is loaded with this and it returns 'gd loaded'
<?php if (extension_loaded('gd'))
{
echo "gd loaded";
} else {
echo "not loaded";
} ?>
I also tried hooking it into after_theme_setup like this:
function add_custom_sizes() {
add_image_size( 'map-size', 199, 199, array('center','center') );
add_image_size('shop-size', 599, 599, array('center','center') );
add_image_size('discover-size', 749, 620, array('center','center'));
add_image_size( 'map-size1', 198, 199, true );
add_image_size('shop-size1', 598, 599, true );
add_image_size('discover-size1', 748, 620, true);
}
add_action('after_setup_theme','add_custom_sizes');
however as i regenerate it still makes a 198x165 instead of 198x199 (from 768 x 641)
The parent is called 'rise' by thrive themes. I contacted them but they said they don't have support for dev questions.
The parent only uses add_image_size once, i tried removing this but I still had the scaling instead of cropping issue.
I've included the rise files below. I have a hunch they do some kind of custom scaling thing? And i will have to over-ride this some how?
thrive image optimization file - https://pastebin.com/1QEa6YJv thrive functions - https://pastebin.com/pAqBt285
Can anyone help me figure out what i'm doing wrong? Thanks for any help.
array(center,center)
is an array of two constants calledcenter
. These need to be strings:array('center','center')
. Not sure if that's exactly the problem, but it stuck out.thrive_get_theme_options( 'image_optimization_type' )
. Can you reproduce the issue with this option turned Off? (2) Also, can you test this with another theme activated? (Just to make sure server settings are ok). (3) IsWP_DEBUG
set totrue
inwp-config.php
? It should be, just in case we are missing something here.