admin管理员组文章数量:1315118
I use events manager pro plugin to show an eventslist. These event-list is showing their thumbnail image in the new (wordpress 4.4) wordpress image size "medium_large" (width 768px). I need an image size of 600x255px which is cropped from the center.
How can i update these image size in my functions.php?
I use events manager pro plugin to show an eventslist. These event-list is showing their thumbnail image in the new (wordpress 4.4) wordpress image size "medium_large" (width 768px). I need an image size of 600x255px which is cropped from the center.
How can i update these image size in my functions.php?
Share Improve this question asked Feb 3, 2016 at 16:50 public9nfpublic9nf 3961 gold badge9 silver badges20 bronze badges4 Answers
Reset to default 2According to what has been written in the documentation about responsive images in WP:
https://make.wordpress/core/2015/11/10/responsive-images-in-wordpress-4-4/
you should use update_option
(doc here) to change size medium_large images
For example:
update_option('medium_large_size_w',444)
update_option('medium_large_size_h',444)
You can call add_image_size()
again to update the existing image size. Assuming it is called medium_large
(Events Manager Pro is a paid plugin so not very much people have it) you can do something like:
<?php
function update_medium_large_size_wpse216595() {
add_image_size( 'medium_large', 600, 255, array( 'center', 'top' ) );
}
add_action( 'init', 'update_medium_large_size_wpse216595', 11 );
Then you will need to regenerate the thumbnails. Although I am not 100% sure that init
is the right hook for the job.
p.s. You can check this if you are using a child theme.
p.s. 2. I am not sure that I understand the center cropping correctly. You many need to play with it a bit. array( 'center', 'top' )
will crop the picture in the center ('trimming' the right and left part).
I tried to update the image size with:
add_image_size( 'medium_large', 600, 255, array( 'center', 'top' ) );
But when i update the image size with height, width and crop, wordpress is just using the "large" image-size. When i just use add_image_size with the width argument:
add_image_size('medium_large', 600, '', true);
The image size gets updatet to 600px. Any idea what the problem could be?
If you want to get image to specific size, first you must add image size
add_image_size( 'medium_large', 600, 255, array( 'center', 'top' ) );
You have already upload image before add image size code, You must be regenerate image. You can use Regenerate Thumbnails plugin.
本文标签: functionsChange size and crop mediumlarge images
版权声明:本文标题:functions - Change size and crop medium_large images 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741971078a2407842.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论