So here’s what I’m trying to do, basically when the users upload a new image, I want to make an image half that size (keeping the proportion) and half the resolution, but save both versions. Maybe save the original as ‘image-upload.jpg’ and the one I modify using php save it as ‘image-upload-halved.jpg’
I’ve messed around with wordpress filters, but can’t seem to get it. Below is along the lines of what I was thinking I should do, but I really have no idea.
add_filter('wp_handle_upload_prefilter', 'custom_upload_filter' );
function custom_upload_filter( $file ){
// here I was hoping I could do the image manipulation
// and also save both versions of the image
}
Any advice or links to other wordpress filters that might fit the job better would be awesome, too.
Thanks!
Take a look at the documentation for
add_image_size
https://developer.wordpress.org/reference/functions/add_image_size/You should be able to add a new image size like this:
Replace “custom-size” with a name for your size and the pixel values that you want.
You can call the image in your template like this: