I’m looking for a way to hook into the process of uploading a featured image. Ideally I would want to be able to do some stuff right when the upload has finished, before the thumbnails are generated.
What I wanna do is when the image is finished uploading, the user will be presented with the possibility to resize and crop their image before it’s actually set as the featured image.
Is this possible, or should I rather be thinking of a custom uploader that I use to later set the finished image as the featured image?
There is a deault feature available on WP to crop image once you upload. You can edit the image you upload and can crop image with
How to crop rotate scale and flip images in wordpress
WordPress by default is designed to generate 3 types of cropping of any uploaded images (Media) automatically to ensure site speed with different sizes where necessary. So, with uploading the Original image there would be at least 4 files-
The Original File (not-cropped), => the_post_thumbnail('full'); // Original image resolution (unmodified) Large, => the_post_thumbnail('large'); // Large resolution (default 640px x 640px max) Medium, and => the_post_thumbnail('medium'); // Medium resolution (default 300px x 300px max) Thumbnail. => the_post_thumbnail('thumbnail'); // Thumbnail (default 150px x 150px max) Custom size the_post_thumbnail( array(100,100) ); // Other resolutions
You can add other custom size with your preference as:
=> add_image_size() //will automatically create the versions of the images suitable for positioning in your website theme.
Using add_image_size() function with your desired parameter allows you to add new size for your site. Use the function into your functions.php to add your desired image size:
Hope that helps!!