Plugin Directory

Changeset 177108


Ignore:
Timestamp:
11/26/2009 01:57:15 AM (16 years ago)
Author:
fitztrev
Message:

v1.4 - and better docs

Location:
wordpress-comment-images/trunk
Files:
3 added
1 edited
1 moved

Legend:

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

    r79048 r177108  
    33Contributors: fitztrev
    44Requires at least: 2.6
    5 Tested up to: 2.7
    6 Stable tag: 1.3
     5Tested up to: 2.9
     6Stable tag: 1.4
    77
    88Comment Image Embedder is a very simple plugin that, once installed, lets your visitors add an image to their comments.
     9
     10== Description ==
     11
     12Comment Image Embedder is a very simple plugin that, once installed, lets your visitors add an image to their comments.
     13
     14It’s rather common for a WordPress user to ask how visitors can embed images in the comments section of their blogs.
     15
     16This plugin will add a link just below the comment box that a user can click on. When clicked, a prompt will appear for the user to enter the URL of the image. It will then be added to their comment.
     17
     18Trevor Fitzgerald
     19http://trevorfitzgerald.com/
    920
    1021== Installation ==
     
    15264. Activate via the administration interface
    1627
    17 == Importance ==
     28== Frequently Asked Questions ==
    1829
    19 It’s rather common for a WordPress user to ask how visitors can embed images in the comments section of their blogs. I’ve been asked it a few times myself, and was never sure how to do it... until now.
     30= How do I fix the image size? =
    2031
    21 --Trevor Fitzgerald
     32Using your stylesheet, you can adjust the height and width of the images that are displayed. If, for instance, you want the maximum width to be 200 pixels, you can use the CSS max-width property like so.
    2233
    23 http://www.trevorfitzgerald.com/
     34`.comments img {
     35    max-width: 200px;
     36}`
     37
     38*Check the comments container id or class for what to use in place of '.comments'
  • wordpress-comment-images/trunk/comment-images/wp-comment-images.php

    r177098 r177108  
    22/*
    33Plugin Name: Comment Image Embedder
    4 Plugin URI: http://www.trevorfitzgerald.com/projects/wordpress-comment-images/
     4Plugin URI: http://trevorfitzgerald.com/wordpress-comment-images/
    55Description: Allows your commenters to post images from external sites in comments with a simple interface.
    6 Version: 1.3
     6Version: 1.4
    77Author: Trevor Fitzgerald
    8 Author URI: http://www.trevorfitzgerald.com/
     8Author URI: http://trevorfitzgerald.com/
    99*/
    1010
    11 function embed_images_js() {
    12     echo "<script type='text/javascript'>
    13         function embed_comment_image() {
    14             var URL = prompt('Enter the Image URL:');
    15             if (URL) {
    16                 document.getElementById('comment').value = document.getElementById('comment').value + '[img]' + URL + '[/img]';
    17             }
    18         }
    19     </script>
    20     ";
    21 }
    22 
    23 
    24 // Accepts 2 formats:
    25 // 1.)  [img]http://image.gif[/img]
    26 // 2.)  [img=http://image.gif]
    2711function embed_images($content) {
    2812    $content = preg_replace('/\[img=?\]*(.*?)(\[\/img)?\]/e', '"<img src=\"$1\" alt=\"" . basename("$1") . "\" />"', $content);
     
    3115
    3216function embed_image_instructions($id) {
    33     echo "<p>You can add images to your comment by <a href='#' onclick='embed_comment_image(); return false;'>clicking here</a>.</p>";
     17    echo '<p>You can add images to your comment by <a id="addCommentImage" href="#">clicking here</a>.</p>';
    3418    return $id;
    3519}
     
    3721add_filter('comment_text', 'embed_images');
    3822add_action('comment_form', 'embed_image_instructions');
    39 add_action('wp_head', 'embed_images_js');
     23wp_enqueue_script('comment-images', plugins_url('js/comment-images.js', __FILE__), array('jquery'), '1.4');
     24
    4025?>
Note: See TracChangeset for help on using the changeset viewer.