Is it possible to hook in to action when uploading and resizing specific size added by add_image_size( 'mini-placeholder', 32 ) for image in Wordpress, and remove EXIF Data, and set quality of this one to minimum (10/20%)?

I want to achieve small thumb under 1kb (the goal is smallest as it is possible).


Assuming you are using ImageMagick (the WP standard) as your library there is a filter called image_strip_meta which controls whether the EXIF data must be preserved. Normally you would just use a boolean to do an overall setting, but you could easily make that a function like this:

add_filter ('image_strip_meta','wpse239481_conditional_strip')

function wpse239481_conditional_strip {
  if (...condition ..) return true else return false;

The problem is in the condition. You would need to access the current thumbnail label, which doesn't trickle down from the multi_resize method that sets thing going. However, the target width and height are known in the resize function where the filter resides. Still, you can't access those dimensions inside the filter unless you hack the core to make this instance of apply_filters pass parameters.

Unless of course, someone smarter than me knows a trick.

  • Ok, I understand. Maybe I'll try to hook when attachment is uploaded,and create custom resize function. I tried filter add_filter ('add_attachment ','new_atachment' ); But it wont work. – Isu Sep 19 '16 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.