Plugin Directory

Changeset 709027


Ignore:
Timestamp:
05/07/2013 04:08:14 AM (13 years ago)
Author:
sewpafly
Message:

4.0 includes a wordpress3.6 fix plus some enhancements to the shortcode creator

Location:
post-thumbnail-extras/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • post-thumbnail-extras/trunk/README.txt

    r705227 r709027  
    44Tags: post-thumbnail, post thumbnail, featured image, awesome, media library, shortcode, shortcodes
    55Requires at least: 2.5
    6 Tested up to: 3.5.1
     6Tested up to: 3.6
    77Stable tag: trunk
    88License: GPLv2
     
    1414= Features =
    1515
    16 * Provides a shortcode as a wrapper for the `wp_get_attachment_image` call. Allows your posts to quickly change the picture in your posts without wading through HTML (nice if your post-thumbnails change width or height due to a theme change or you have cropped them with another tool -- this will always pull the latest image from wordpress).
     16* Provides a shortcode for embedding post-thumbnails. Authors can quickly change pictures in posts without wading through HTML.  This can be awesome in several ways: if your post-thumbnails change the width or height due to a theme change, or if you have cropped them with another tool -- this will always pull wordpress' latest image).
    1717* Includes a hook into the media library to create the above shortcode.
    18 * Add and manage post thumbnails via the media screen.
     18* Add new post thumbnails via Wordpress Settings → Media.
    1919
    2020= Future Plans =
    2121
    22 In the future, there will be support for changing the default option, and any other ideas I can come up with. Submit any other ideas at https://github.com/sewpafly/post-thumbnail-extras/issues.
     22Submit any other ideas at https://github.com/sewpafly/post-thumbnail-extras/issues.
    2323
    2424== Installation ==
     
    2828Use the shortcode `[pt]` in your posts to quickly embed the featured image as a thumbnail. Use the attribute 'size' to change to a different post-thumbnail size (e.g. `[pt size='medium']`). You can also use any image in your media gallery if you know the id, by using the `id` attribute (`[pt id='100']`).
    2929
    30 Use the media library to quickly add this shortcode by pressing the "Insert shortcode button".
     30Use the `link` attribute to wrap the image in a link.
     31* `link='file'` will create a link to the full size image.
     32* `link='post'` will create a link to the attachment page.
     33* `link='http...'` creates a link to any URL.
     34
     35Use the media library to quickly add this shortcode for the selected image by pressing the "Insert shortcode" button.
    3136
    3237= Add/Delete Post Thumbnails =
    3338
    34391. In Settings → Media, click the plus sign to add a new post thumbnail.
    35 2. Update the width/height and whether or not the post-thumbnail should be cropped to an exact size. (If the width or height is set to 0, that boundary constraint is not enforced). Make sure you click the "save" button so that the changes are stored in the database.
     402. Update the width/height and whether or not the post-thumbnail should be cropped to an exact size. (If the width or height is set to 0, that boundary constraint is not enforced -- effectively, it's infinite). Make sure you click the "save" button so that the changes are stored in the database.
    3641
    3742== Frequently Asked Questions ==
     
    3944= Did you even test this? =
    4045
    41 Yes. No. Sort of. Thanks for asking. But [let me know if you're having problems](https://github.com/sewpafly/post-thumbnail-extra/issues) and I'll see what I can do.
     46Yes. No. Sort of. Thanks for asking. But [let me know if you're having problems](https://github.com/sewpafly/post-thumbnail-extras/issues) and I'll see what I can do.
    4247
    4348== Screenshots ==
    4449
    45501. In Settings → Media, click the plus sign to add a new post thumbnail.
    46 2. Update the width/height and whether or not the post-thumbnail should be cropped to an exact size. (If the width or height is set to 0, that boundary constraint is not enforced). Make sure you click the "save" button so that the changes are stored in the database.
    47 3. In the media editor, you can choose to insert a shortcode of a single picture with the new button.
     512. Update the width/height and whether or not the post-thumbnail should be cropped to an exact size. (If the width or height is set to 0, that boundary constraint is not enforced). Make sure you click the "Save Changes" button so that the changes are stored in the database.
     523. In the media editor, you can choose to insert a shortcode of a single picture with the "Insert shortcode" button.
    4853
    4954== Changelog ==
     55
     56= 4.0 =
     57* Added alignment and link options to the shortcode
     58* Wordpress 3.6-beta2 fix
    5059
    5160= 3.0 =
     
    6069
    6170== Upgrade Notice ==
    62 = 3.0 =
    63 Integration with the Media Library for shortcode creation
     71= 4.0 =
     72Better shortcodes and bug fixes
  • post-thumbnail-extras/trunk/js/media-shortcode.js

    r705217 r709027  
    5454      $.when.apply( $, selection.map( function( attachment ) {
    5555         var display = state.display( attachment ).toJSON();
    56          return "[pt id="+ attachment.id +" size='"+ display.size +"']";
     56         var shortcode = {};
     57         shortcode.id = attachment.id;
     58         if (display.size != 'thumbnail')
     59            shortcode.size = display.size;
     60         if (display.link != 'none')
     61            shortcode.link = (display.link != 'custom') ? display.link : display.linkUrl;
     62         if (display.align != 'none')
     63            shortcode['class'] = "align" + display.align;
     64         // Take all the attributes and create a string of key=value pairs to pass to the
     65         // shortcode
     66         var attributes = _.map(shortcode, function(v,k){ return k + "='" + v + "'";})
     67         return "[pt " + attributes.join(" ") + "]";
    5768      } ) ).done( function() {
    5869         //}, this ) ).done( function() {
     
    6475   $(function(){
    6576      // Get the content frame - This is _the_ instance of the MediaFrame created above
    66       var frame = wp.media.editor.add('content')
    6777      // Set a trigger to call our function when our button is pressed
    68       frame.on('ptx_shortcode', _.bind(createPTXShortcode, frame));
     78      var ptx_editor_add = _.bind(wp.media.editor.add, wp.media.editor);
     79      wp.media.editor.add = function(id, options) {
     80         var frame = ptx_editor_add(id, options);
     81         frame.on('ptx_shortcode', _.bind(createPTXShortcode, frame));
     82         return frame;
     83      };
    6984   });
    7085
  • post-thumbnail-extras/trunk/php/options.php

    r705217 r709027  
    44    public function __construct() {
    55        add_action( 'admin_init', array( $this, 'admin_init' ) );
     6
     7        if ( false !== $ptx_post_thumbnails = get_option( 'ptx_post_thumbnails' ) ) {
     8            foreach ( $ptx_post_thumbnails as $thumbnail ){
     9                add_image_size( $thumbnail['name']
     10                    , $thumbnail['width']
     11                    , $thumbnail['height']
     12                    , $thumbnail['crop']
     13                );
     14            }
     15        }
    616    }
    717
  • post-thumbnail-extras/trunk/php/shortcode.php

    r705217 r709027  
    1818     *          [id] the id of the image to use from the media library - defaults to the featured-image
    1919     *          [size] the post-thumbnail size to use
     20     *          [link] where should the link point to? 'file', 'post', 'none', or an arbitrary URL.
    2021     *  @return string HTML content to display post-thumbnail.
    2122     */
     
    2526            'id' => get_post_thumbnail_id( $post->ID ),
    2627            'size' => 'thumbnail',
    27             'class' => 'pt-post-thumbnail'
     28            'class' => 'pt-post-thumbnail',
     29            'link' => 'none'
    2830        ), $attrs ) );
    2931
    30         return wp_get_attachment_image( $id, $size, false, array( 'class' => $class ) );
     32        if ( ! wp_attachment_is_image( $id ) ) return;
     33
     34        $html = wp_get_attachment_image( $id, $size, false, array( 'class' => $class ) );
     35
     36        switch( $link ) {
     37        case 'none':
     38            return $html;
     39            break;
     40        case 'file':
     41            $link_url = wp_get_attachment_url( $id );
     42            break;
     43        case 'post':
     44            $link_url = get_attachment_link( $id );
     45            break;
     46        default:
     47            $link_url = $link;
     48        }
     49
     50        return "<a href='$link_url'>$html</a>";
    3151    }
    3252
  • post-thumbnail-extras/trunk/post-thumbnail-extras.php

    r705217 r709027  
    55Author: sewpafly
    66Author URI: http://sewpafly.github.io/post-thumbnail-editor/
    7 Version: 3.0
     7Version: 4.0
    88Description: Little things that make using post thumbnails easier
    99*/
     
    1616
    1717class PostThumbnailExtras {
    18     public function __construct(){
     18    public function __construct() {
    1919        // Wordpress hooks and settings
    2020        add_action( 'init', array( $this, 'i18n' ) );
    21 
    22         if ( false !== $ptx_post_thumbnails = get_option( 'ptx_post_thumbnails' ) ) {
    23             foreach ( get_option( 'ptx_post_thumbnails' ) as $thumbnail ){
    24                 add_image_size( $thumbnail['name']
    25                     , $thumbnail['width']
    26                     , $thumbnail['height']
    27                     , $thumbnail['crop']
    28                 );
    29             }
    30         }
    3121
    3222        /*
     
    3929     * Internationalization and Localization
    4030     */
    41     public function i18n(){
     31    public function i18n() {
    4232        $locale = apply_filters( 'plugin_locale', get_locale(), PTX_DOMAIN );
    4333        load_textdomain( PTX_DOMAIN
     
    5242    );
    5343
    54     private function load_requires(){
     44    private function load_requires() {
    5545        $path = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
    5646        foreach ( $this->requires as $require ){
Note: See TracChangeset for help on using the changeset viewer.