Last active
September 30, 2021 15:50
-
-
Save justinemter/931ab9ffe05301103e59ea6fc990ec5d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add to functions.php in Wordpress to strip EXIF metadata from images upon upload.
Requires imagemagick:
sudo apt install imagemagicksudo apt install php-imagicksudo systemctl restart apache2php -m | grep imagick