WordPress.org

Plugin Directory

Changeset 641468


Ignore:
Timestamp:
12/19/12 02:59:29 (16 months ago)
Author:
greenshady
Message:

Version 0.8.1 updates.

Location:
get-the-image
Files:
6 added
3 edited

Legend:

Unmodified
Added
Removed
  • get-the-image/trunk/get-the-image.php

    r556924 r641468  
    44 * Plugin URI: http://themehybrid.com/plugins/get-the-image 
    55 * Description: This is a highly intuitive script that can grab an image by custom field input, post attachment, or extracting it from the post's content. 
    6  * Version: 0.8 
     6 * Version: 0.8.1 
    77 * Author: Justin Tadlock 
    88 * Author URI: http://justintadlock.com 
     
    1717 * 
    1818 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU  
    19  * General Public License version 2, as published by the Free Software Foundation.  You may NOT assume  
    20  * that you can use any other version of the GPL. 
     19 * General Public License as published by the Free Software Foundation; either version 2 of the License,  
     20 * or (at your option) any later version. 
    2121 * 
    2222 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without  
    2323 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
    2424 * 
    25  * @package GetTheImage 
    26  * @version 0.8.0 
    27  * @author Justin Tadlock <justin@justintadlock.com> 
     25 * @package   GetTheImage 
     26 * @version   0.8.1 
     27 * @author    Justin Tadlock <justin@justintadlock.com> 
    2828 * @copyright Copyright (c) 2008 - 2012, Justin Tadlock 
    29  * @link http://justintadlock.com/archives/2008/05/27/get-the-image-wordpress-plugin 
    30  * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 
     29 * @link      http://justintadlock.com/archives/2008/05/27/get-the-image-wordpress-plugin 
     30 * @license   http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 
    3131 */ 
    3232 
     
    5858    /* Set the default arguments. */ 
    5959    $defaults = array( 
    60         'meta_key' =>       array( 'Thumbnail', 'thumbnail' ), // array|string 
    61         'post_id' =>        get_the_ID(), 
    62         'attachment' =>         true, 
    63         'the_post_thumbnail' =>     true, // WP 2.9+ image function 
    64         'size' =>           'thumbnail', 
    65         'default_image' =>  false, 
    66         'order_of_image' =>     1, 
    67         'link_to_post' =>       true, 
    68         'image_class' =>        false, 
    69         'image_scan' =>         false, 
    70         'width' =>      false, 
    71         'height' =>         false, 
    72         'format' =>         'img', 
    73         'meta_key_save' =>  false, 
    74         'thumbnail_id_save' =>  false, // Set 'featured image'. 
    75         'callback' =>       null, 
    76         'cache' =>      true, 
    77         'before' =>         '', 
    78         'after' =>      '', 
    79         'echo' =>       true, 
    80         'custom_key' =>         null, // @deprecated 0.6. Use 'meta_key'. 
    81         'default_size' =>       null, // @deprecated 0.5.  Use 'size'. 
     60        'meta_key'           => array( 'Thumbnail', 'thumbnail' ), // array|string 
     61        'post_id'            => get_the_ID(), 
     62        'attachment'         => true, 
     63        'the_post_thumbnail' => true, // WP 2.9+ image function 
     64        'size'               => 'thumbnail', 
     65        'default_image'      => false, 
     66        'order_of_image'     => 1, 
     67        'link_to_post'       => true, 
     68        'image_class'        => false, 
     69        'image_scan'         => false, 
     70        'width'              => false, 
     71        'height'             => false, 
     72        'format'             => 'img', 
     73        'meta_key_save'      => false, 
     74        'thumbnail_id_save'  => false, // Set 'featured image'. 
     75        'callback'           => null, 
     76        'cache'              => true, 
     77        'before'             => '', 
     78        'after'              => '', 
     79        'echo'               => true, 
     80        'custom_key'         => null, // @deprecated 0.6. Use 'meta_key'. 
     81        'default_size'       => null, // @deprecated 0.5.  Use 'size'. 
    8282    ); 
    8383 
     
    116116 
    117117    /* If there is no cached image, let's see if one exists. */ 
    118     if ( !isset( $image_cache[$key] ) || empty( $cache ) ) { 
     118    if ( !isset( $image_cache[ $key ] ) || empty( $cache ) ) { 
    119119 
    120120        /* If a custom field key (array) is defined, check for images by custom field. */ 
     
    147147            /* If $meta_key_save was set, save the image to a custom field. */ 
    148148            if ( !empty( $meta_key_save ) ) 
    149                 get_the_image_meta_key_save( $args, $image['src'] ); 
     149                get_the_image_meta_key_save( $args, $image ); 
    150150 
    151151            /* Format the image HTML. */ 
     
    153153 
    154154            /* Set the image cache for the specific post. */ 
    155             $image_cache[$key] = $image_html; 
     155            $image_cache[ $key ] = $image_html; 
    156156            wp_cache_set( $post_id, $image_cache, 'get_the_image' ); 
    157157        } 
     
    177177        /* Loop through the image attributes and add them in key/value pairs for the return array. */ 
    178178        foreach ( $atts as $att ) 
    179             $out[$att['name']] = $att['value']; 
     179            $out[ $att['name'] ] = $att['value']; 
    180180 
    181181        $out['url'] = $out['src']; // @deprecated 0.5 Use 'src' instead of 'url'. 
     
    187187    /* Or, if $echo is set to false, return the formatted image. */ 
    188188    elseif ( false === $echo ) { 
    189         return $args['before'] . $image_html . $args['after']; 
     189        return !empty( $image_html ) ? $args['before'] . $image_html . $args['after'] : $image_html; 
    190190    } 
    191191 
     
    195195 
    196196    /* Display the image if we get to this point. */ 
    197     echo $args['before'] . $image_html . $args['after']; 
     197    echo !empty( $image_html ) ? $args['before'] . $image_html . $args['after'] : $image_html; 
    198198 
    199199    /* If there is a $post_thumbnail_id, do the actions associated with get_the_post_thumbnail(). */ 
     
    205205 
    206206/** 
    207  * Calls images by custom field key.  Script loops through multiple custom field keys.  If that particular key  
    208  * is found, $image is set and the loop breaks.  If an image is found, it is returned. 
     207 * Calls images by custom field key.  Script loops through multiple custom field keys.  If that particular  
     208 * key is found, $image is set and the loop breaks.  If an image is found, it is returned. 
    209209 * 
    210210 * @since 0.7.0 
     
    294294        $attachments = get_children( 
    295295            array( 
    296                 'post_parent' => $args['post_id'], 
    297                 'post_status' => 'inherit', 
    298                 'post_type' => 'attachment', 
    299                 'post_mime_type' => 'image', 
    300                 'order' => 'ASC', 
    301                 'orderby' => 'menu_order ID', 
     296                'post_parent'      => $args['post_id'], 
     297                'post_status'      => 'inherit', 
     298                'post_type'        => 'attachment', 
     299                'post_mime_type'   => 'image', 
     300                'order'            => 'ASC', 
     301                'orderby'          => 'menu_order ID', 
    302302                'suppress_filters' => true 
    303303            ) 
     
    327327 
    328328        /* Get the attachment image. */ 
    329         $image = wp_get_attachment_image_src( $id, $args['size'] ); 
     329        $image = wp_get_attachment_image_src( $attachment_id, $args['size'] ); 
    330330 
    331331        /* Get the attachment excerpt. */ 
    332         $alt = trim( strip_tags( get_post_field( 'post_excerpt', $id ) ) ); 
     332        $alt = trim( strip_tags( get_post_field( 'post_excerpt', $attachment_id ) ) ); 
    333333 
    334334        /* Save the attachment as the 'featured image'. */ 
    335335        if ( true === $args['thumbnail_id_save'] ) 
    336             set_post_thumbnail( $args['post_id'], $id ); 
     336            set_post_thumbnail( $args['post_id'], $attachment_id ); 
    337337 
    338338        /* Return the image URL. */ 
  • get-the-image/trunk/readme.html

    r556924 r641468  
    5151 
    5252<pre><code>$defaults = array( 
    53     'meta_key' => array( 'Thumbnail', 'thumbnail' ), // array|string 
    54     'post_id' => get_the_ID(), 
    55     'attachment' => true, 
     53    'meta_key'           => array( 'Thumbnail', 'thumbnail' ), // array|string 
     54    'post_id'            => get_the_ID(), 
     55    'attachment'         => true, 
    5656    'the_post_thumbnail' => true, // WP 2.9+ image function 
    57     'size' => 'thumbnail', 
    58     'default_image' => false, 
    59     'order_of_image' => 1, 
    60     'link_to_post' => true, 
    61     'image_class' => false, 
    62     'image_scan' => false, 
    63     'width' => false, 
    64     'height' => false, 
    65     'format' => 'img', 
    66     'meta_key_save' => false, 
    67     'thumbnail_id_save' => false, // Set 'featured image'. 
    68     'callback' => null, 
    69     'cache' => true, 
    70     'before' => '', 
    71     'after' => '', 
    72     'echo' => true, 
    73     'custom_key' => null, // @deprecated 0.6. Use 'meta_key'. 
    74     'default_size' => null, // @deprecated 0.5.  Use 'size'. 
     57    'size'               => 'thumbnail', 
     58    'default_image'      => false, 
     59    'order_of_image'     => 1, 
     60    'link_to_post'       => true, 
     61    'image_class'        => false, 
     62    'image_scan'         => false, 
     63    'width'              => false, 
     64    'height'             => false, 
     65    'format'             => 'img', 
     66    'meta_key_save'      => false, 
     67    'thumbnail_id_save'  => false, // Set 'featured image'. 
     68    'callback'           => null, 
     69    'cache'              => true, 
     70    'before'             => '', 
     71    'after'              => '', 
     72    'echo'               => true, 
     73    'custom_key'         => null, // @deprecated 0.6. Use 'meta_key'. 
     74    'default_size'       => null, // @deprecated 0.5.  Use 'size'. 
    7575);</code></pre> 
    7676 
     
    215215<p>This plugin is copyrighted to <a href="http://justintadlock.com" title="Justin Tadlock">Justin Tadlock</a>.</p> 
    216216 
    217 <p>2008&thinsp;&ndash;&thinsp;2012 &copy; Justin Tadlock.  All rights reserved.</p> 
     217<p>2008&thinsp;&ndash;&thinsp;2012 &copy; Justin Tadlock..</p> 
    218218 
    219219</body> 
  • get-the-image/trunk/readme.txt

    r556924 r641468  
    11=== Get the Image === 
    22Contributors: greenshady 
    3 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3687060 
     3Donate link: http://themehybrid.com/donate 
    44Tags: image, images, thumbnail 
    55Requires at least: 3.2 
    6 Tested up to: 3.4 
    7 Stable tag: 0.8 
     6Tested up to: 3.5 
     7Stable tag: 0.8.1 
    88 
    99An easy-to-use image script for adding things such as thumbnails and feature images. 
     
    1414 
    1515This is a highly intuitive script that can grab an image by custom field input, WP's post image feature, post attachment, or extracting it from the post's content. 
     16 
     17Support for this plugin is handled on the Theme Hybrid <a href="http://themehybrid.com/support">support forums</a>. 
    1618 
    1719== Installation == 
     
    3638 
    37391.  Looks for an image by custom field (one of your choosing). 
    38 1. If no image is added by custom field, check for an image using `the_post_thumbnail()` (WP 2.9's new image feature). 
     401. If no image is added by custom field, check for an image using `the_post_thumbnail()` (WordPress featured image). 
    39411. If no image is found, it grabs an image attached to your post. 
    40421. If no image is attached, it can extract an image from your post content (off by default). 
     
    5658 
    5759== Changelog == 
     60 
     61**Version 0.8.1** 
     62 
     63* Use correct `$attachment_id` variable instead of `$id`. 
     64* Pass full `$image` array to the `get_the_image_meta_key_save()` function so that it saves correctly. 
     65* Only use `before` and `after` arguments if an image is found. 
     66* General code formatting updated. 
    5867 
    5968**Version 0.8** 
Note: See TracChangeset for help on using the changeset viewer.