Changeset 666836
- Timestamp:
- 02/12/2013 12:41:55 PM (13 years ago)
- Location:
- image-metadata-cruncher/trunk
- Files:
-
- 2 edited
-
README.txt (modified) (3 diffs)
-
image-metadata-cruncher.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
image-metadata-cruncher/trunk/README.txt
r654286 r666836 5 5 Requires at least: 2.7 6 6 Tested up to: 3.5 7 Stable tag: 1. 57 Stable tag: 1.6 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 10 11 Gives you ultimate controll over which image metadata WordPress extracts from an uploaded image 12 and where and in what form it then goes. 11 A versatile Swiss Army Knife for extraction and processing of IPTC, EXIF and other image metadata. 13 12 14 13 == Description == 15 14 16 When you upload an image in the WordPress admin, WordPress extracts the **EXIF ImageDescription** metadata to the 17 **Description** field and the **IPTC Headline** to the **Title** field of 18 the form that gets displayed after the image has been uploaded.15 A must have tool for photographers who edit their images in **Lightroom** or **Photomechanic** and 16 don't want to waste their precious time by writing all the **keywords** and **categories** 17 once again by hand. 19 18 20 The **Image Metadata Cruncher** plugin lets you choose what metadata will be extracted from the uploaded image and 21 in which fields of the form they appear. 19 WordPress by default extracts the **EXIF ImageDescription** of an uploaded image to 20 the **Description** field and the **IPTC Headline** to the **Title** field of 21 the **Edit Media** form. 22 22 23 Moreover, the plugin's simple templating system allows you to prefill the form with complex strings like 24 *Image was taken with Canon 7D, exposure was 1/125s and aperture was f/2.8*. 23 **Image Metadata Cruncher** gives you ultimate controll over this behaviour. 24 You decide what metadata gets where and in what form. 25 26 27 Moreover, the plugin's simple but powerfull templating system allows you to 28 convert the extracted metadata into complex strings like: 29 30 > Image was taken with Canon 7D, exposure was 1/125s and aperture was f/2.8. 25 31 26 32 You can even extract metadata to unlimited custom **post meta** that will be saved with the image to the database. … … 37 43 38 44 == Changelog == 45 46 = 1.6 = 47 * Fixed a bug when the **enable highlighting** option didn't get saved. 48 * Fixed some potential security issues. 39 49 40 50 = 1.5 = … … 58 68 59 69 60 -
image-metadata-cruncher/trunk/image-metadata-cruncher.php
r652940 r666836 3 3 Plugin Name: Image Metadata Cruncher 4 4 Description: Gives you ultimate controll over which image metadata (EXIF or IPTC) WordPress extracts from an uploaded image and where and in what form it then goes. You can even specify unlimited custom post meta tags as the target of the extracted image metadata. 5 Version: 1. 55 Version: 1.6 6 6 Author: Peter Hudec 7 7 Author URI: http://peterhudec.com … … 18 18 // stores metadata between wp_handle_upload_prefilter and add_attachment hooks 19 19 private $metadata; 20 20 21 private $keyword; 21 22 private $keywords; 22 23 private $pattern; 23 24 public $plugin_name = 'Image Metadata Cruncher'; 24 private $version = 1. 5;25 private $version = 1.6; 25 26 private $after_update = FALSE; 26 27 private $settings_slug = 'image_metadata_cruncher-options'; 28 private $donate_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RJYHYJJD2VKAN'; 27 29 28 30 /** … … 94 96 95 97 /** 96 * The add_attachment hook gets triggered when the attachment post is created 97 * in Wordpress media uploads are handled as posts98 * The add_attachment hook gets triggered when the attachment post is created. 99 * In Wordpress media uploads are handled as posts. 98 100 */ 99 101 public function add_attachment( $post_ID ) { … … 125 127 } 126 128 127 // finally update post 129 // finally sanitize and update post 130 sanitize_post( $post ); 128 131 wp_update_post( $post ); 129 132 } … … 226 229 227 230 /** 228 * Replaces template tags in template string 231 * Replaces template tags in template string. 229 232 * 230 * @return Template string with processed template tags233 * @return Sanitized template string with processed template tags. 231 234 */ 232 235 private function render_template( $template ){ … … 257 260 $result = str_replace(array('\{', '\}'), array('{', '}'), $result); 258 261 259 return $result;262 return sanitize_text_field( $result ); 260 263 } 261 264 … … 440 443 foreach ( $keywords as $keyword ) { 441 444 // search for key in metadata extracted from the image 445 446 //TODO: Sanitize? 442 447 $meta = $this->get_meta_by_key( trim( $keyword ), $delimiter ); 443 448 … … 450 455 return str_replace( 451 456 array( 452 '\$', // replace escaped dolar sign with some unusual character like: ⌨457 '\$', // replace escaped dolar sign with some unusual unicode character 453 458 '$', // replace dolar signs for meta value 454 459 '\"', // replace escaped doublequote for doublequote 455 ' ⌨' // replace ⌨with dolar sign460 '\u2328' // replace \u2328 with dolar sign 456 461 ), 457 462 array( 458 ' ⌨',463 '\u2328', 459 464 $meta, 460 465 '"', … … 615 620 public function defaults() { 616 621 add_option( $this->prefix, array( 617 'version' => 1.1,622 'version' => $this->version, 618 623 'title' => '{ IPTC:Headline }', 619 624 'alt' => '', … … 798 803 $options = get_option( $this->prefix ); 799 804 800 if ( intval( $options['version'] ) < 1.1 ) { 801 // if the plugin has been updated to version 1.1 enable highlighting by default 805 if ( intval( $options['version'] ) > 1.0 ) { 806 //TODO: Move to defaults 807 // if the plugin has been updated from version 1.0 enable highlighting by default 802 808 $options['enable_highlighting'] = 'enable'; 803 $options['version'] = 1.1;809 $options['version'] = $this->version; 804 810 update_option( $this->prefix, $options ); 805 811 } … … 847 853 <th>Delete</th> 848 854 </thead> 849 <?php if ( is_array( $options['custom_meta'] ) ): ?> 850 <?php foreach ( $options['custom_meta'] as $key => $value ): ?> 851 <tr> 852 <td><input type="text" class="name" value="<?php echo $key ?>" /></td> 853 <td> 854 <div class="highlighted ce" contenteditable="true"><?php echo $value ?></div> 855 <?php // used textarea because hidden input caused bugs when whitespace got converted to ?> 856 <textarea class="hidden-input template" name="<?php echo $this->prefix; ?>[custom_meta][<?php echo $key ?>]" ><?php echo $value ?></textarea> 857 </td> 858 <td><button class="button">Remove</button></td> 859 </tr> 860 <?php endforeach; ?> 855 <?php if ( isset( $options['custom_meta'] ) ) : ?> 856 <?php if ( is_array( $options['custom_meta'] ) ): ?> 857 <?php foreach ( $options['custom_meta'] as $key => $value ): ?> 858 <?php 859 $key = sanitize_text_field($key); 860 $value = sanitize_text_field($value); 861 ?> 862 <tr> 863 <td><input type="text" class="name" value="<?php echo $key ?>" /></td> 864 <td> 865 <div class="highlighted ce" contenteditable="true"><?php echo $value ?></div> 866 <?php // used textarea because hidden input caused bugs when whitespace got converted to ?> 867 <textarea class="hidden-input template" name="<?php echo $this->prefix; ?>[custom_meta][<?php echo $key ?>]" ><?php echo $value ?></textarea> 868 </td> 869 <td><button class="button">Remove</button></td> 870 </tr> 871 <?php endforeach; ?> 872 <?php endif ?> 861 873 <?php endif ?> 862 874 </table> … … 1468 1480 * General callback for media form fields 1469 1481 */ 1470 private function cb( $key ) { ?> 1471 <?php $options = get_option( $this->prefix ); ?> 1472 <div class="highlighted ce" contenteditable="true"><?php echo $options[$key]; ?></div> 1482 private function cb( $key ) { 1483 $options = get_option( $this->prefix ); 1484 $value = sanitize_text_field($options[$key]); 1485 $key = sanitize_text_field($key); 1486 ?> 1487 1488 <div class="highlighted ce" contenteditable="true"><?php echo $value; ?></div> 1473 1489 <?php // used textarea because hidden input caused bugs when whitespace got converted to ?> 1474 <textarea class="hidden-input" id="<?php echo $this->prefix; ?>[<?php echo $key; ?>]" name="<?php echo $this->prefix; ?>[<?php echo $key; ?>]"><?php echo $ options[$key]; ?></textarea>1490 <textarea class="hidden-input" id="<?php echo $this->prefix; ?>[<?php echo $key; ?>]" name="<?php echo $this->prefix; ?>[<?php echo $key; ?>]"><?php echo $value; ?></textarea> 1475 1491 <?php } 1476 1492
Note: See TracChangeset
for help on using the changeset viewer.