wp-smushit
Last commit date
JSON
17 years ago
history.txt
17 years ago
license.txt
17 years ago
options.php
17 years ago
readme.txt
16 years ago
screenshot-1.jpg
17 years ago
smush.php
17 years ago
wp-smushit.php
17 years ago
smush.php
29 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Admin page for manually smushing an attachment. |
| 4 | * |
| 5 | * Expects an `attachment_ID` in the query string. |
| 6 | * |
| 7 | * @version 1.2 |
| 8 | * @package WP_SmushIt |
| 9 | */ |
| 10 | |
| 11 | if ( !isset($_GET['attachment_ID']) ) |
| 12 | wp_die('Must provide attachment ID'); |
| 13 | |
| 14 | $attachment_ID = intval($_GET['attachment_ID']); |
| 15 | |
| 16 | |
| 17 | $original_meta = wp_get_attachment_metadata( $attachment_ID ); |
| 18 | |
| 19 | |
| 20 | $new_meta = wp_smushit_resize_from_meta_data( $original_meta ); |
| 21 | |
| 22 | wp_update_attachment_metadata( $attachment_ID, $new_meta ); |
| 23 | |
| 24 | $sendback = wp_get_referer(); |
| 25 | $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); |
| 26 | |
| 27 | wp_redirect($sendback); |
| 28 | |
| 29 | exit(0); |