Version Description
- Don't show set as links in media screens when not in context (props prettyboymp). Add voceplatforms as an author. Updated FAQ.
Download this release
Release Info
Developer | chrisscott |
Plugin | Multiple Post Thumbnails |
Version | 1.3 |
Comparing to | |
See all releases |
Code changes from version 1.1 to 1.3
- multi-post-thumbnails.php +12 -4
- readme.txt +33 -8
multi-post-thumbnails.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Multiple Post Thumbnails
|
4 |
Plugin URI: http://wordpress.org/extend/plugins/multiple-post-thumbnails/
|
5 |
Description: Adds the ability to add multiple post thumbnails to a post type.
|
6 |
-
Version: 1.
|
7 |
Author: Chris Scott
|
8 |
Author URI: http://vocecommuncations.com/
|
9 |
*/
|
@@ -81,7 +81,7 @@ if (!class_exists('MultiPostThumbnails')) {
|
|
81 |
|
82 |
add_action('add_meta_boxes', array($this, 'add_metabox'));
|
83 |
add_filter('attachment_fields_to_edit', array($this, 'add_attachment_field'), 20, 2);
|
84 |
-
add_action('
|
85 |
add_action("wp_ajax_set-{$this->post_type}-{$this->id}-thumbnail", array($this, 'set_thumbnail'));
|
86 |
add_action('delete_attachment', array($this, 'action_delete_attachment'));
|
87 |
}
|
@@ -119,6 +119,9 @@ if (!class_exists('MultiPostThumbnails')) {
|
|
119 |
$calling_post_id = absint($_GET['post_id']);
|
120 |
elseif (isset($_POST) && count($_POST)) // Like for async-upload where $_GET['post_id'] isn't set
|
121 |
$calling_post_id = $post->post_parent;
|
|
|
|
|
|
|
122 |
|
123 |
// check the post type to see if link needs to be added
|
124 |
$calling_post = get_post($calling_post_id);
|
@@ -140,8 +143,13 @@ if (!class_exists('MultiPostThumbnails')) {
|
|
140 |
*
|
141 |
* @return void
|
142 |
*/
|
143 |
-
public function enqueue_admin_scripts() {
|
144 |
-
|
|
|
|
|
|
|
|
|
|
|
145 |
}
|
146 |
|
147 |
/**
|
3 |
Plugin Name: Multiple Post Thumbnails
|
4 |
Plugin URI: http://wordpress.org/extend/plugins/multiple-post-thumbnails/
|
5 |
Description: Adds the ability to add multiple post thumbnails to a post type.
|
6 |
+
Version: 1.3
|
7 |
Author: Chris Scott
|
8 |
Author URI: http://vocecommuncations.com/
|
9 |
*/
|
81 |
|
82 |
add_action('add_meta_boxes', array($this, 'add_metabox'));
|
83 |
add_filter('attachment_fields_to_edit', array($this, 'add_attachment_field'), 20, 2);
|
84 |
+
add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
|
85 |
add_action("wp_ajax_set-{$this->post_type}-{$this->id}-thumbnail", array($this, 'set_thumbnail'));
|
86 |
add_action('delete_attachment', array($this, 'action_delete_attachment'));
|
87 |
}
|
119 |
$calling_post_id = absint($_GET['post_id']);
|
120 |
elseif (isset($_POST) && count($_POST)) // Like for async-upload where $_GET['post_id'] isn't set
|
121 |
$calling_post_id = $post->post_parent;
|
122 |
+
|
123 |
+
if (!$calling_post_id)
|
124 |
+
return $form_fields;
|
125 |
|
126 |
// check the post type to see if link needs to be added
|
127 |
$calling_post = get_post($calling_post_id);
|
143 |
*
|
144 |
* @return void
|
145 |
*/
|
146 |
+
public function enqueue_admin_scripts( $hook ) {
|
147 |
+
// only load on select pages
|
148 |
+
if ( ! in_array( $hook, array( 'post-new.php', 'post.php', 'media-upload-popup' ) ) )
|
149 |
+
return;
|
150 |
+
|
151 |
+
add_thickbox();
|
152 |
+
wp_enqueue_script( "featured-image-custom", $this->plugins_url( 'js/multi-post-thumbnails-admin.js', __FILE__ ), array( 'jquery', 'media-upload' ) );
|
153 |
}
|
154 |
|
155 |
/**
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== Plugin Name ===
|
2 |
-
Contributors: chrisscott
|
3 |
Tags: thumbnails, image, featured image
|
4 |
Requires at least: 2.9.2
|
5 |
Tested up to: 3.3.2
|
6 |
-
Stable tag: 1.
|
7 |
|
8 |
Adds multiple post thumbnails to a post type. If you've ever wanted more than one Featured Image on a post, this plugin is for you.
|
9 |
|
@@ -22,13 +22,13 @@ Adds multiple post thumbnails to a post type. If you've ever wanted more than on
|
|
22 |
)
|
23 |
);
|
24 |
}
|
25 |
-
4. Display the thumbnail in your theme:
|
26 |
|
27 |
-
<?php if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail(
|
28 |
|
29 |
== Frequently Asked Questions ==
|
30 |
|
31 |
-
= I'm trying to upgrade to a new
|
32 |
|
33 |
This is caused by using the example in previous readmes that didn't do a check for the `MultiPostThumbnails` class existing first. This has been corrected in the Installation section.
|
34 |
|
@@ -56,10 +56,14 @@ After you have registered a new post thumbnail, register a new image size for it
|
|
56 |
|
57 |
This will register a new image size of 250x150 px. Then, when you display the thumbnail in your theme, update the call to `MultiPostThumbnails::the_post_thumbnail()` to pass in the image size:
|
58 |
|
59 |
-
MultiPostThumbnails::the_post_thumbnail(
|
60 |
|
61 |
You can register multiple image sizes for a given thumbnail if desired.
|
62 |
|
|
|
|
|
|
|
|
|
63 |
= How do I get just the URL of a thumbnail without the wrapping HTML? =
|
64 |
|
65 |
Use `MultiPostThumbnails::get_post_thumbnail_url()` passing in the following arguments:
|
@@ -70,12 +74,25 @@ Use `MultiPostThumbnails::get_post_thumbnail_url()` passing in the following arg
|
|
70 |
|
71 |
For example, for a thumbnail registered with an `id` of `secondary-image` and `post_type` of `post` the following would retrieve the thumbnail URL:
|
72 |
|
73 |
-
MultiPostThumbnails::get_post_thumbnail_url(
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
= I see the meta box in the admin when editing a post but when I click on 'Set as [label] image' in the media manager, nothing happens and I get a JavaScript console error =
|
76 |
|
77 |
If you are using a symlink to include the plugin directory in your project, the admin js file will not load and cause this. Unfortunately, the solution is to not use symlinks due to the behavior of PHP's `__FILE__`
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
== Screenshots ==
|
80 |
|
81 |
1. Admin meta box showing a new thumbnail named 'Secondary Image'.
|
@@ -84,9 +101,17 @@ If you are using a symlink to include the plugin directory in your project, the
|
|
84 |
|
85 |
== Changelog ==
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
= 1.1 =
|
88 |
|
89 |
-
* Update FAQ. Clean up `readme`. Don't yell `null`. Don't output link to original if there is no image.
|
90 |
|
91 |
= 1.0 =
|
92 |
|
1 |
=== Plugin Name ===
|
2 |
+
Contributors: chrisscott, voceplatforms
|
3 |
Tags: thumbnails, image, featured image
|
4 |
Requires at least: 2.9.2
|
5 |
Tested up to: 3.3.2
|
6 |
+
Stable tag: 1.3
|
7 |
|
8 |
Adds multiple post thumbnails to a post type. If you've ever wanted more than one Featured Image on a post, this plugin is for you.
|
9 |
|
22 |
)
|
23 |
);
|
24 |
}
|
25 |
+
4. Display the thumbnail in your theme. e.g. for loop templates (outside of the loop, the first argument to `MultiPostThumbnails::the_post_thumbnail()` will need to be the post type):
|
26 |
|
27 |
+
<?php if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image'); endif; ?>
|
28 |
|
29 |
== Frequently Asked Questions ==
|
30 |
|
31 |
+
= I'm trying to upgrade to a new versions of WordPress and get an error about `MultiPostThumbnails` =
|
32 |
|
33 |
This is caused by using the example in previous readmes that didn't do a check for the `MultiPostThumbnails` class existing first. This has been corrected in the Installation section.
|
34 |
|
56 |
|
57 |
This will register a new image size of 250x150 px. Then, when you display the thumbnail in your theme, update the call to `MultiPostThumbnails::the_post_thumbnail()` to pass in the image size:
|
58 |
|
59 |
+
MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image', NULL, 'post-secondary-image-thumbnail');
|
60 |
|
61 |
You can register multiple image sizes for a given thumbnail if desired.
|
62 |
|
63 |
+
= How can I get the thumbnail without automatically echoing it? =
|
64 |
+
|
65 |
+
Use `MultiPostThumbnails::get_the_post_thumbnail()` in place of `MultiPostThumbnails::the_post_thumbnail()`.
|
66 |
+
|
67 |
= How do I get just the URL of a thumbnail without the wrapping HTML? =
|
68 |
|
69 |
Use `MultiPostThumbnails::get_post_thumbnail_url()` passing in the following arguments:
|
74 |
|
75 |
For example, for a thumbnail registered with an `id` of `secondary-image` and `post_type` of `post` the following would retrieve the thumbnail URL:
|
76 |
|
77 |
+
MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'secondary-image');
|
78 |
+
|
79 |
+
= When I use the sample code the thumbnail doesn't show up. What's wrong? =
|
80 |
+
|
81 |
+
* Make sure you are using the same ID you registered the thumbnail with as the second argument to `MultiPostThumbnails::the_post_thumbnail()`.
|
82 |
+
* If you are trying to get the thumbnail outside of the loop or a single template, you will need to replace `get_post_type()` with the post type you are trying to get the thumbnail for. This is common when trying to use the code in headers/footers/sidebars.
|
83 |
|
84 |
= I see the meta box in the admin when editing a post but when I click on 'Set as [label] image' in the media manager, nothing happens and I get a JavaScript console error =
|
85 |
|
86 |
If you are using a symlink to include the plugin directory in your project, the admin js file will not load and cause this. Unfortunately, the solution is to not use symlinks due to the behavior of PHP's `__FILE__`
|
87 |
|
88 |
+
= Is there a github repo? I love me some submodules! =
|
89 |
+
|
90 |
+
Yes. https://github.com/voceconnect/multi-post-thumbnails
|
91 |
+
|
92 |
+
= Pancakes or waffles? =
|
93 |
+
|
94 |
+
Pancakes.
|
95 |
+
|
96 |
== Screenshots ==
|
97 |
|
98 |
1. Admin meta box showing a new thumbnail named 'Secondary Image'.
|
101 |
|
102 |
== Changelog ==
|
103 |
|
104 |
+
= 1.3 =
|
105 |
+
|
106 |
+
* Don't show set as links in media screens when not in context (props prettyboymp). Add voceplatforms as an author. Updated FAQ.
|
107 |
+
|
108 |
+
= 1.2 =
|
109 |
+
|
110 |
+
* Only enqueue admin scripts on needed pages (props johnjamesjacoby) and make sure thickbox is loaded (props prettyboymp). Add media-upload script to dependencies for post types that don't already require it (props kevinlangleyjr).
|
111 |
+
|
112 |
= 1.1 =
|
113 |
|
114 |
+
* Update FAQ. Clean up `readme`. Don't yell `null`. Don't output link to original if there is no image.
|
115 |
|
116 |
= 1.0 =
|
117 |
|