Changeset 709027
- Timestamp:
- 05/07/2013 04:08:14 AM (13 years ago)
- Location:
- post-thumbnail-extras/trunk
- Files:
-
- 5 edited
-
README.txt (modified) (5 diffs)
-
js/media-shortcode.js (modified) (2 diffs)
-
php/options.php (modified) (1 diff)
-
php/shortcode.php (modified) (2 diffs)
-
post-thumbnail-extras.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
post-thumbnail-extras/trunk/README.txt
r705227 r709027 4 4 Tags: post-thumbnail, post thumbnail, featured image, awesome, media library, shortcode, shortcodes 5 5 Requires at least: 2.5 6 Tested up to: 3. 5.16 Tested up to: 3.6 7 7 Stable tag: trunk 8 8 License: GPLv2 … … 14 14 = Features = 15 15 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). 17 17 * 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. 19 19 20 20 = Future Plans = 21 21 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.22 Submit any other ideas at https://github.com/sewpafly/post-thumbnail-extras/issues. 23 23 24 24 == Installation == … … 28 28 Use 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']`). 29 29 30 Use the media library to quickly add this shortcode by pressing the "Insert shortcode button". 30 Use 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 35 Use the media library to quickly add this shortcode for the selected image by pressing the "Insert shortcode" button. 31 36 32 37 = Add/Delete Post Thumbnails = 33 38 34 39 1. 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.40 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 -- effectively, it's infinite). Make sure you click the "save" button so that the changes are stored in the database. 36 41 37 42 == Frequently Asked Questions == … … 39 44 = Did you even test this? = 40 45 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.46 Yes. 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. 42 47 43 48 == Screenshots == 44 49 45 50 1. 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 newbutton.51 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 Changes" button so that the changes are stored in the database. 52 3. In the media editor, you can choose to insert a shortcode of a single picture with the "Insert shortcode" button. 48 53 49 54 == Changelog == 55 56 = 4.0 = 57 * Added alignment and link options to the shortcode 58 * Wordpress 3.6-beta2 fix 50 59 51 60 = 3.0 = … … 60 69 61 70 == Upgrade Notice == 62 = 3.0 =63 Integration with the Media Library for shortcode creation 71 = 4.0 = 72 Better shortcodes and bug fixes -
post-thumbnail-extras/trunk/js/media-shortcode.js
r705217 r709027 54 54 $.when.apply( $, selection.map( function( attachment ) { 55 55 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(" ") + "]"; 57 68 } ) ).done( function() { 58 69 //}, this ) ).done( function() { … … 64 75 $(function(){ 65 76 // Get the content frame - This is _the_ instance of the MediaFrame created above 66 var frame = wp.media.editor.add('content')67 77 // 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 }; 69 84 }); 70 85 -
post-thumbnail-extras/trunk/php/options.php
r705217 r709027 4 4 public function __construct() { 5 5 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 } 6 16 } 7 17 -
post-thumbnail-extras/trunk/php/shortcode.php
r705217 r709027 18 18 * [id] the id of the image to use from the media library - defaults to the featured-image 19 19 * [size] the post-thumbnail size to use 20 * [link] where should the link point to? 'file', 'post', 'none', or an arbitrary URL. 20 21 * @return string HTML content to display post-thumbnail. 21 22 */ … … 25 26 'id' => get_post_thumbnail_id( $post->ID ), 26 27 'size' => 'thumbnail', 27 'class' => 'pt-post-thumbnail' 28 'class' => 'pt-post-thumbnail', 29 'link' => 'none' 28 30 ), $attrs ) ); 29 31 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>"; 31 51 } 32 52 -
post-thumbnail-extras/trunk/post-thumbnail-extras.php
r705217 r709027 5 5 Author: sewpafly 6 6 Author URI: http://sewpafly.github.io/post-thumbnail-editor/ 7 Version: 3.07 Version: 4.0 8 8 Description: Little things that make using post thumbnails easier 9 9 */ … … 16 16 17 17 class PostThumbnailExtras { 18 public function __construct() {18 public function __construct() { 19 19 // Wordpress hooks and settings 20 20 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 }31 21 32 22 /* … … 39 29 * Internationalization and Localization 40 30 */ 41 public function i18n() {31 public function i18n() { 42 32 $locale = apply_filters( 'plugin_locale', get_locale(), PTX_DOMAIN ); 43 33 load_textdomain( PTX_DOMAIN … … 52 42 ); 53 43 54 private function load_requires() {44 private function load_requires() { 55 45 $path = dirname( __FILE__ ) . DIRECTORY_SEPARATOR; 56 46 foreach ( $this->requires as $require ){
Note: See TracChangeset
for help on using the changeset viewer.