Skip to content

Instantly share code, notes, and snippets.

@justinemter
Last active September 30, 2021 15:50
Show Gist options
  • Select an option

  • Save justinemter/931ab9ffe05301103e59ea6fc990ec5d to your computer and use it in GitHub Desktop.

Select an option

Save justinemter/931ab9ffe05301103e59ea6fc990ec5d to your computer and use it in GitHub Desktop.
/**
* Strip EXIF data from images upon upload.
*/
add_filter('wp_handle_upload_prefilter', 'custom_upload_filter' );
function custom_upload_filter( $file ){
$image = $file['tmp_name'];
try
{
$img = new Imagick($image);
$img->stripImage();
$img->writeImage($image);
$img->clear();
$img->destroy();
} catch(Exception $e) {
//
}
return $file;
}
@justinemter
Copy link
Author

justinemter commented Jul 22, 2019

Add to functions.php in Wordpress to strip EXIF metadata from images upon upload.

Requires imagemagick:

sudo apt install imagemagick

sudo apt install php-imagick

sudo systemctl restart apache2

php -m | grep imagick

@marcorroma
Copy link

Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment