Plugin Directory

Changeset 666836


Ignore:
Timestamp:
02/12/2013 12:41:55 PM (13 years ago)
Author:
PeterHudec
Message:

Updated trunk

Location:
image-metadata-cruncher/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • image-metadata-cruncher/trunk/README.txt

    r654286 r666836  
    55Requires at least: 2.7
    66Tested up to: 3.5
    7 Stable tag: 1.5
     7Stable tag: 1.6
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    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.
     11A versatile Swiss Army Knife for extraction and processing of IPTC, EXIF and other image metadata.
    1312
    1413== Description ==
    1514
    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.
     15A must have tool for photographers who edit their images in **Lightroom** or **Photomechanic** and
     16don't want to waste their precious time by writing all the **keywords** and **categories**
     17once again by hand.
    1918
    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.
     19WordPress by default extracts the **EXIF ImageDescription** of an uploaded image to
     20the **Description** field and the **IPTC Headline** to the **Title** field of
     21the **Edit Media** form.
    2222
    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.
     24You decide what metadata gets where and in what form.
     25
     26
     27Moreover, the plugin's simple but powerfull templating system allows you to
     28convert 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.
    2531
    2632You can even extract metadata to unlimited custom **post meta** that will be saved with the image to the database.
     
    3743
    3844== Changelog ==
     45
     46= 1.6 =
     47* Fixed a bug when the **enable highlighting** option didn't get saved.
     48* Fixed some potential security issues.
    3949
    4050= 1.5 =
     
    5868
    5969
    60 
  • image-metadata-cruncher/trunk/image-metadata-cruncher.php

    r652940 r666836  
    33Plugin Name: Image Metadata Cruncher
    44Description: 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.5
     5Version: 1.6
    66Author: Peter Hudec
    77Author URI: http://peterhudec.com
     
    1818    // stores metadata between wp_handle_upload_prefilter and add_attachment hooks
    1919    private $metadata;
     20   
    2021    private $keyword;
    2122    private $keywords;
    2223    private $pattern;
    2324    public $plugin_name = 'Image Metadata Cruncher';
    24     private $version = 1.5;
     25    private $version = 1.6;
    2526    private $after_update = FALSE;
    2627    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';
    2729   
    2830    /**
     
    9496   
    9597    /**
    96      * The add_attachment hook gets triggered when the attachment post is created
    97      * in Wordpress media uploads are handled as posts
     98     * The add_attachment hook gets triggered when the attachment post is created.
     99     * In Wordpress media uploads are handled as posts.
    98100     */
    99101    public function add_attachment( $post_ID ) {
     
    125127        }
    126128       
    127         // finally update post
     129        // finally sanitize and update post
     130        sanitize_post( $post );
    128131        wp_update_post( $post );
    129132    }
     
    226229   
    227230    /**
    228      * Replaces template tags in template string
     231     * Replaces template tags in template string.
    229232     *
    230      * @return Template string with processed template tags
     233     * @return Sanitized template string with processed template tags.
    231234     */
    232235    private function render_template( $template ){
     
    257260        $result = str_replace(array('\{', '\}'), array('{', '}'), $result);
    258261       
    259         return $result;
     262        return sanitize_text_field( $result );
    260263    }
    261264   
     
    440443        foreach ( $keywords as $keyword ) {
    441444            // search for key in metadata extracted from the image
     445           
     446            //TODO: Sanitize?
    442447            $meta = $this->get_meta_by_key( trim( $keyword ), $delimiter );
    443448           
     
    450455                    return str_replace(
    451456                        array(
    452                             '\$', // replace escaped dolar sign with some unusual character like: ⌨
     457                            '\$', // replace escaped dolar sign with some unusual unicode character
    453458                            '$', // replace dolar signs for meta value
    454459                            '\"', // replace escaped doublequote for doublequote
    455                             '⌨' // replace ⌨ with dolar sign
     460                            '\u2328' // replace \u2328 with dolar sign
    456461                        ),
    457462                        array(
    458                             '',
     463                            '\u2328',
    459464                            $meta,
    460465                            '"',
     
    615620    public function defaults() {
    616621        add_option( $this->prefix, array(
    617             'version' => 1.1,
     622            'version' => $this->version,
    618623            'title' => '{ IPTC:Headline }',
    619624            'alt' => '',
     
    798803        $options = get_option( $this->prefix );
    799804       
    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
    802808            $options['enable_highlighting'] = 'enable';
    803             $options['version'] = 1.1;
     809            $options['version'] = $this->version;
    804810            update_option( $this->prefix, $options );
    805811        }
     
    847853                <th>Delete</th>
    848854            </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 &nbsp; ?>
    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 &nbsp; ?>
     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 ?>
    861873            <?php endif ?>
    862874        </table>
     
    14681480     * General callback for media form fields
    14691481     */
    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>
    14731489        <?php // used textarea because hidden input caused bugs when whitespace got converted to &nbsp; ?>
    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>
    14751491    <?php }
    14761492   
Note: See TracChangeset for help on using the changeset viewer.