Wordpress select and crop in plugin

1k views Asked by At

I needs to upload images in my plugin and use wp.media for this task. According to https://codex.wordpress.org/Javascript_Reference/wp.media

Its work, but I needs to have "Select and Crop" option in media library after upload my image with custom size.

I was see this in default theme in appearence custom header image, but can't understand how I can use this in my plugin with wp.media js?

2

There are 2 answers

0
Matej Đaković On

This my not be better solution but work in wordpress :) i use Thumbnail Crop Position and Simple Image Sizes for that :) Good luck! :)

<?php if ( has_post_thumbnail() ) {
 the_post_thumbnail('yourImageSize'); 
}?>
0
Darren On

See my answer posted here that does Select and Crop using the Media Library on a theme options page. You can use it as a starting point for getting it to work in a plugin: https://wordpress.stackexchange.com/questions/281760/using-media-uploader-to-select-image-of-specific-size-enforce-cropper/302962#302962