简体   繁体   中英

Custom image size WordPress

I'm building a custom blog listing page for a Wordpress site and trying to use a custom image size. The height of the images should be a hard 300px. All images are taller than this, so not worried about smaller images.

The width I would like to be 500px. This is where I'm having issues. I'm trying to use the Wordpress add_image_size function for this, but I keep getting a crop of exact dimensions.

Example, I use the following code, and it gives me an exact 300x300 pixel image:

add_image_size( 'blog-two', 500, 300);

I've even tried adding the hard crop value to this and not getting the desired result of a 500x300 pixel cropped image.

add_image_size( 'blog-two', 500, 300, true);

Is this function depreciated? Or am I missing something?

Did you add the add_image_size() to your functions.php file, if so your code should function properly?

There might be more guidance in this similar question .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM