Title: [Plugin: Comment Images] Size limit
Last modified: August 20, 2016

---

# [Plugin: Comment Images] Size limit

 *  Resolved [junger](https://wordpress.org/support/users/junger/)
 * (@junger)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-comment-images-size-limit/)
 * Great plugin! Is there a way to set a limit on the size of the images uploaded?
 * The limit would be either dimensions or file size.
 * Thanks!
 * [http://wordpress.org/extend/plugins/comment-images/](http://wordpress.org/extend/plugins/comment-images/)

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/plugin-comment-images-size-limit/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-comment-images-size-limit/page/2/?output_format=md)

 *  [Tom McFarlin](https://wordpress.org/support/users/tommcfarlin/)
 * (@tommcfarlin)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-comment-images-size-limit/#post-2972830)
 * Thanks!
 * Currently there is no way to set a limit on the size of the images being uploaded.
   I’ll make a note of this and see about adding something like this in a future
   version.
 *  [mcmillad](https://wordpress.org/support/users/mcmillad/)
 * (@mcmillad)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-comment-images-size-limit/#post-2972945)
 * I was having this problem also and changing the css for the plugin didn’t work(
   noticed it was inactive after messing with it). I simply went in to my themes
   css and inserted the following code and it works great.
 * /******************************************
    Comment Image Picture Control ******************************************/.
   comment-image img { max-width: 400px; }
 * Of course just set the max-width to whatever looks good on your site. I hope 
   this helps.
 *  [Tom McFarlin](https://wordpress.org/support/users/tommcfarlin/)
 * (@tommcfarlin)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-comment-images-size-limit/#post-2972946)
 * Thanks for sharing this. In the next version of the plugin, I plan to have this
   resolved.
 *  [Li-An](https://wordpress.org/support/users/li-an/)
 * (@li-an)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/plugin-comment-images-size-limit/#post-2972964)
 * Very nice idea. But the best feature should be a resize of the uploaded image
   so the page will not be too heavy to load.
 *  [Tom McFarlin](https://wordpress.org/support/users/tommcfarlin/)
 * (@tommcfarlin)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/plugin-comment-images-size-limit/#post-2972965)
 * Noted – will see what I can do in a future version!
 * Thanks for the suggestion!
 *  [nootkan](https://wordpress.org/support/users/nootkan/)
 * (@nootkan)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/plugin-comment-images-size-limit/#post-2973000)
 * Awesome, thanks for this short term fix. Looking forward to the updated version
   of a great plugin.
 *  [breadtopia](https://wordpress.org/support/users/breadtopia/)
 * (@breadtopia)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/plugin-comment-images-size-limit/#post-2973001)
 * Would also just like to second (or third or whatever) the motion to be able to
   auto downsize images so they fit the area. Would gladly purchase a reliable supported
   comment image upload plugin.
 * Another awesome feature would be a lightbox type thing so double clicking a thumbnail
   image would expand it in pop up window.
 *  [Tom McFarlin](https://wordpress.org/support/users/tommcfarlin/)
 * (@tommcfarlin)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/plugin-comment-images-size-limit/#post-2973002)
 * Breadtopia,
 * I hear you loud and clear!
 * I always appreciate the feedback and I’m aiming to have these features baked 
   in as soon as I can get some time.
 * Also, I appreciate the thought on paying for a premium version of the plugin.
   That’s something I’ll definitely consider.
 * Love all the feedback – keep it coming!
 *  [breadtopia](https://wordpress.org/support/users/breadtopia/)
 * (@breadtopia)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/plugin-comment-images-size-limit/#post-2973003)
 * Sounds good. Just having a receptive developer is a bonus!
 * I’ve been through a few comment image plugins that either aren’t quite good enough
   and/or no longer supported. Such a plugin is invaluable for our site so I’m surprised
   there there doesn’t seem to be more demand for it.
 * Since the beginning I’ve had to use a programmer to add code or whatever to get
   them to do what I want. Having just discovered yours, they are working on it 
   as I type. Hopefully they’ll also get it to pull in all the previously uploaded
   images from the now defunct plugin I was using.
 *  [Tom McFarlin](https://wordpress.org/support/users/tommcfarlin/)
 * (@tommcfarlin)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/plugin-comment-images-size-limit/#post-2973004)
 * Completely understand.
 * I’d love for this to be the de-facto Comment Images plugin, but I’ve just gotta
   find the time to work in these feature requests.
 * Believe me: I’m just as impatient as you guys when it comes to want it done ;).
   Just have a backlog of some other stuff for the time being.
 *  [gnickoloff](https://wordpress.org/support/users/gnickoloff/)
 * (@gnickoloff)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/plugin-comment-images-size-limit/#post-2973012)
 * Just thought I’d “bump” this thread… I could use the image re-sample function.
   
   Thanks for great work!
 *  [Tom McFarlin](https://wordpress.org/support/users/tommcfarlin/)
 * (@tommcfarlin)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/plugin-comment-images-size-limit/#post-2973013)
 * Thanks gnickoloff!
 * This hasn’t been forgotten – just haven’t had a chance to work on the plugin 
   lately.
 * For those that are curious, this is likely how the plugin will work:
    - On each post’s page, you’ll set a maximum size for the image (in MB)
    - The comment form will display a note, if there is a limit
    - If the image uploaded is greater than the size specified, then the user will
      be given a warning and the image will fail to load
 * Hope this clarifies where things are heading (at least in the future :).
 *  [ianarmstrong](https://wordpress.org/support/users/ianarmstrong/)
 * (@ianarmstrong)
 * [12 years, 12 months ago](https://wordpress.org/support/topic/plugin-comment-images-size-limit/#post-2973016)
 * Haven’t had time in ten months? You’ve got a very popular plugin man, at least
   stick it on Git and request a fork.
 *  [Tom McFarlin](https://wordpress.org/support/users/tommcfarlin/)
 * (@tommcfarlin)
 * [12 years, 12 months ago](https://wordpress.org/support/topic/plugin-comment-images-size-limit/#post-2973017)
 * [@ianarmstrong](https://wordpress.org/support/users/ianarmstrong/)
 * The plugin hasn’t [_not_](http://wordpress.org/plugins/comment-images/changelog/)
   been updated; however, this is one feature I just haven’t gotten to implementing
   yet.
 *  [ianarmstrong](https://wordpress.org/support/users/ianarmstrong/)
 * (@ianarmstrong)
 * [12 years, 12 months ago](https://wordpress.org/support/topic/plugin-comment-images-size-limit/#post-2973018)
 * Good to know. I can get it to die if I do a file check but it does an ugly die
   and then posts the comments with the image stripped anyway. It’s sub-optimal.
   I can remove the else and it posts the comment but silently strips the image.
 *     ```
       // If the nonce is valid and the user uploaded an image that is less than 150kb, let's upload it to the server
       		if( isset( $_FILES[ $comment_image_id ] ) && ! empty( $_FILES[ $comment_image_id ] ) ) {
                   if ( $_FILES[ $comment_image_id ]['size'] < 153600 ) {
   
                       // Store the parts of the file name into an array
                       $file_name_parts = explode( '.', $_FILES[ $comment_image_id ]['name'] );
   
                       // If the file is valid, upload the image, and store the path in the comment meta
                       if( $this->is_valid_file_type( $file_name_parts[ count( $file_name_parts ) - 1 ] ) ) {;
   
                           // Upload the comment image to the uploads directory
                           $comment_image_file = wp_upload_bits( $_FILES[ $comment_image_id ]['name'], null, file_get_contents( $_FILES[ $comment_image_id ]['tmp_name'] ) );
   
                           // Now, we need to actually create a post so that this shows up in the media uploader
                           $img_url = media_sideload_image( $comment_image_file['url'], $post_id );
   
                           // And strip out the name of the image file so we can save this to the meta data
                           // Regex is usually bad for this, but WordPress is predictable in the format
                           preg_match_all( "#[^<img src='](.*)[^'alt='' />]#", $img_url, $matches );
                           $comment_image_file['url'] = $matches[0][0];
   
                           // Set post meta about this image. Need the comment ID and need the path.
                           if( false == $comment_image_file['error'] ) {
   
                               // Since we've already added the key for this, we'll just update it with the file.
                               add_comment_meta( $comment_id, 'comment_image', $comment_image_file );
   
                           } // end if/else
   
                       } // end if
   
                   } else { die; }
               }
       ```
   

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/plugin-comment-images-size-limit/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-comment-images-size-limit/page/2/?output_format=md)

The topic ‘[Plugin: Comment Images] Size limit’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/comment-images_eaeaea.svg)
 * [Comment Images](https://wordpress.org/plugins/comment-images/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/comment-images/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/comment-images/)
 * [Active Topics](https://wordpress.org/support/plugin/comment-images/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/comment-images/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/comment-images/reviews/)

 * 21 replies
 * 9 participants
 * Last reply from: [roland_susan](https://wordpress.org/support/users/roland_susan/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/plugin-comment-images-size-limit/page/2/#post-2973024)
 * Status: resolved