Site logo

Archived topic

Problem setting custom image sizes

3 replies · Started by Shawn on April 4, 2019

Viewing posts 1–4 of 4

Hi,

Late last month, I had problems creating custom image sizes.

I want to add a third custom size image (1024×1000), so I tried:

add_action( ‘after_setup_theme’, function() {
add_image_size( ‘horiz-med’, 800, 526, true );
add_image_size( ‘vert-med’, 800, 1050, true );
add_image_size( ‘horiz-1024’, 1024, 1000 true );
} );

I received the message:
Your PHP code changes were rolled back due to an error on line 19 of file wp-content/themes/generatepress_child/functions.php. Please fix and try saving again.

I don’t know what to fix as I don’t know what’s causing the error. I had this problem a few weeks ago when I wanted to add the vert-med 800, 1050 image. At that time I was advised to add the code:

add_action( ‘after_setup_theme’, function() {
add_image_size( ‘horiz-med’, 800, 526, true );
add_image_size( ‘vert-med’, 800, 1050, true );
} );

That worked and allowed for the second custom image size (800, 1050). I tried doing the same thing for the third custom size (1024, 1000 as noted in the add_action string at the beginning of this email.) All I got was the error message noted above

Any suggestions would be great.

Thanks.

Hi there,

could be because of the missing , (comma) before the True value:

add_image_size( ‘horiz-1024’, 1024, 1000 true );

Can you double check?

That's it, thanks David.

Glad to be of help.

This archived topic is closed to new replies.