开发者 | volkmar-kantor |
---|---|
更新时间 | 2024年10月27日 06:14 |
捐献地址: | 去捐款 |
PHP版本: | 7.4.0 及以上 |
WordPress版本: | 6.6.2 |
版权: | GPL v3 |
版权网址: | 版权信息 |
The plugin do not add additional image sizes, it only provides functionality to edit the crop area.
You can use "add_image_size
" inside your functions.php to add additional cropped image sizes. See "add_image_size" documentation.
`
add_action( 'after_setup_theme', 'my_adjust_image_sizes' );
function my_adjust_image_sizes() {
//add an cropped image-size with 800 x 250 Pixels
add_image_size( 'my-custom-image-size', 800, 250, true );
/
* The following image sizes use a dynamic value.
* USE WITH CARE
* Also the plugin supports these image-sizes, i do not recommend them!
/
//a dynamic cropped image size with 500 pixel height and the width of the original image
add_image_size( 'my-dynamic-width-1', 9999, 500, true );
//a dynamic cropped image with the same ratio as the original image and 500 pixel width
add_image_size( 'my-dynamic-zero-height-1', 500, 0, true );
}
After you add the image-size any futher image uploads will produce a cropped image "my-custom-image-size" which you can use in post-loop:
if ( has_post_thumbnail() ) { the_post_thumbnail( 'my-custom-image-size' ); }`
true
" (hard crop mode - see: http://codex.wordpress.org/Function_Reference/add_image_size).0
", the plugin will crop it in the ratio of the original image.9999
", the plugin will change the 9999 to the actual size of the current original image.If you had viewed your image on the site before, your browser has cached the image. You can hard refresh the page by hitting:
CTRL + F5
" (on Windows)Apple + R
" or "command + R
" (on Mac/Apple)No. The purpose of this plugin is to provide control for the wordpress automatic crop. If you want to crop let's say the full-size image you should
A documentation with a list of all actions and filters can be found on the Github page of the project.
You can add the following filter in the functions.php of your theme to adjust the ratio of one or more specified image-sizes.
CAUTION: use only when the ratios are really close.
add_filter( 'crop_thumbnails_editor_printratio', 'my_crop_thumbnails_editor_printratio', 10, 2); function my_crop_thumbnails_editor_printratio( $printRatio, $imageSizeName) { if($imageSizeName === 'strange-image-ratio') { $printRatio = '4:3';//do override ratio } return $printRatio; }
Yeah, there is a way. After the crop-thumbnails-modal closed it triggeres a javascript event on the body element. You could use jQuery to cache-break your cropped thumbnail (in backend-view).
The event called "cropThumbnailModalClosed". The plugin also provides a global function that could be called (only in post-edit-view and mediathek) to do the cache-break.
Example-Code:
$('body').on('cropThumbnailModalClosed',function() { CROP_THUMBNAILS_DO_CACHE_BREAK( $('.your-image-selector') ); });
You may have a look on the Translation Page.
Fantastic, i published the code on github. But be warned, i am carefully evaluate new features. If you fork and planning to publish the forked plugin, please contact me.