WordPress.org

Plugin Directory

Changeset 587444


Ignore:
Timestamp:
08/19/12 18:58:45 (20 months ago)
Author:
tommcfarlin
Message:
  • Resolving a bug that prevents comment images that are uploaded back-to-back from properly displaying.
Location:
comment-images/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • comment-images/trunk/README.txt

    r586933 r587444  
    55Requires at least: 3.4.1 
    66Tested up to: 3.4.1 
    7 Stable tag: 1.3 
     7Stable tag: 1.4 
    88License: GPLv2 or later 
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    5959== Changelog == 
    6060 
     61= 1.4 = 
     62* Resolving a bug that prevents comment images that are uploaded back-to-back from properly displaying. 
     63 
    6164= 1.3 = 
    6265* Adding support for comment images on pages 
  • comment-images/trunk/plugin.php

    r586933 r587444  
    44Plugin URI: http://tommcfarlin.com/comment-images 
    55Description: Allow your readers easily to attach an image to their comment. 
    6 Version: 1.3 
     6Version: 1.4 
    77Author: Tom McFarlin 
    88Author URI: http://tommcfarlin.com 
     
    155155     * Adds the comment image upload form to the comment form. 
    156156     * 
    157      * @params  $post_id    The ID of the post on which the comment is being added. 
     157     * @param   $post_id    The ID of the post on which the comment is being added. 
    158158     */ 
    159159    function add_image_upload_form( $post_id ) { 
     
    177177     * Adds the comment image upload form to the comment form. 
    178178     * 
    179      * @params  $comment_id The ID of the comment to which we're adding the image. 
     179     * @param   $comment_id The ID of the comment to which we're adding the image. 
    180180     */ 
    181181    function save_comment_image( $comment_id ) { 
     
    216216     * Appends the image below the content of the comment. 
    217217     * 
    218      * @params  $comment    The content of the comment. 
     218     * @param   $comment    The content of the comment. 
    219219     */ 
    220220    function display_comment_image( $comments ) { 
    221          
    222         // Get the most recent comment 
     221 
     222        // Make sure that there are comments 
    223223        if( count( $comments ) > 0 ) { 
    224224         
    225             $comment = $comments[ count( $comments ) - 1 ]; 
    226      
    227             // If the comment image meta value exists, then render the comment image 
    228             if( false != get_comment_meta( $comment->comment_ID, 'comment_image' ) ) { 
    229              
    230                 // Get the comment image meta 
    231                 $comment_image = get_comment_meta( $comment->comment_ID, 'comment_image', true ); 
    232                  
    233                 // Render it in a paragraph element appended to the comment 
    234                 $comment->comment_content .= '<p class="comment-image">'; 
    235                     $comment->comment_content .= '<img src="' . $comment_image['url'] . '" alt="" />'; 
    236                 $comment->comment_content .= '</p><!-- /.comment-image -->';     
    237                  
    238             } // end if 
    239          
     225            // Loop through each comment... 
     226            foreach( $comments as $comment ) { 
     227             
     228                // ...and if the comment has a comment image... 
     229                if( true == get_comment_meta( $comment->comment_ID, 'comment_image' ) ) { 
     230             
     231                    // ...get the comment image meta 
     232                    $comment_image = get_comment_meta( $comment->comment_ID, 'comment_image', true ); 
     233                     
     234                    // ...and render it in a paragraph element appended to the comment 
     235                    $comment->comment_content .= '<p class="comment-image">'; 
     236                        $comment->comment_content .= '<img src="' . $comment_image['url'] . '" alt="" />'; 
     237                    $comment->comment_content .= '</p><!-- /.comment-image -->';     
     238                 
     239                } // end if 
     240                 
     241            } // end foreach 
     242             
    240243        } // end if 
    241244         
    242245        return $comments; 
    243          
     246 
    244247    } // end display_comment_image 
    245248     
     
    249252     
    250253    /** 
    251      * @params  $type   The file type attempting to be uploaded. 
    252      * @returns         Whether or not the specified file type is able to be uploaded. 
     254     * Determines if the specified type if a valid file type to be uploaded. 
     255     * 
     256     * @param   $type   The file type attempting to be uploaded. 
     257     * @return          Whether or not the specified file type is able to be uploaded. 
    253258     */  
    254259    private function is_valid_file_type( $type ) {  
     
    260265     
    261266    /** 
    262      * @returns         Whether or not the hosting environment supports the ability to upload files. 
     267     * Determines if the hosting environment allows the users to upload files. 
     268     * 
     269     * @return          Whether or not the hosting environment supports the ability to upload files. 
    263270     */  
    264271    private function can_save_files() { 
Note: See TracChangeset for help on using the changeset viewer.