Archived topic
Create Custom Image Sizes
19 replies · Started by Roger on August 7, 2017
Hi,
This is my first post on here, I'm using GP and Elementor Pro. I'm fairly new to both.
I'm creating a new Artist Portfolio site and would like to have some custom image sizes to use when setting up galleries in Elementor - I'm an artist/designer so not a coder so is there an easy way to do this please?
cheers!
Hi there,
Not quite sure what you are after?
If this is to be done with Elementor then it might be better to ask their support.
Let us know :)
hi Leo, sorry, i mean in the Wordpress media library/uploader you have a dropdown menu with a selection of sizes for images and this is the same in Elementor so I'dd like to be able to set my own custom sizes...
cheers
You should be able to use Scale Image in Edit Media through WordPress: https://codex.wordpress.org/Edit_Media#Edit_Image
Thanks, but thats not what i mean - I've seen some themes like customizr i built my first site with has a whole list of custom sizes you can choose to use for that image when you add it to a site in WP but in GP I only have the default sizes that WP uses to resize. The main issue is in elementor I want to have a square image format to control sizes in the Image Gallery Element - as the only options are
Thumbnail
Medium
Medium Large
Large
Full
thanks
You can use the add_image_size() function for that: https://generatepress.com/forums/topic/custom-crop-for-blog-index-featured-images/#post-357876
Thankyou,Tom, ill take a look!
No problem :)
Theres probably a lot of people using Elementor that will find that Action very useful. It surprised me that there wasn't an option in Elementor.....
I just came across this string about custom image sizes. I'm also using the GP theme with Elementor. I need to create additional sizes beyond medium and large but I'm not clear about the add image size function. Based on Tom's link above, does the size information go into the functions section of the parent or child theme?
Thanks.
It would go into the child theme :)
Ok, thanks.
Tom,
This worked great:
add_action('after_setup_theme', 'tu_add_image_sizes');
function tu_add_image_sizes() {
add_image_size( 'horiz-med', 800, 526, true ); // (cropped)
}
When I went back and added another image size by doing this:
add_action('after_setup_theme', 'tu_add_image_sizes');
function tu_add_image_sizes() {
add_image_size( 'horiz-med', 800, 526, true ); // (cropped)
add_image_size( ‘vert-med', 800, 1050, true ); // (cropped)
}
I then received this error message: syntax error, unexpected '', 800, 1050, true ); // (crop' (T_ENCAPSED_AND_WHITESPACE)
What did I do wrong?
Hmm, I'm not seeing anything wrong.
Try this:
add_action( 'after_setup_theme', function() {
add_image_size( 'horiz-med', 800, 526, true );
add_image_size( 'vert-med', 800, 1050, true );
} );
I didn't get an error message adding this code to the php functions.
Thanks.