Default featured image - Version 1.6

Version Description

  • On of the last fixes didn't account for all situations.

=

Download this release

Release Info

Developer janw.oostendorp
Plugin Icon 128x128 Default featured image
Version 1.6
Comparing to
See all releases

Code changes from version 1.5 to 1.6

Files changed (2) hide show
  1. readme.txt +5 -2
  2. set-default-featured-image.php +6 -6
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: janwoostendorp
3
  Tags: media, image
4
  Requires at least: 3.5
5
- Tested up to: 4.5
6
- Stable tag: 1.5
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -127,6 +127,9 @@ yes you can with the filter `dfi_thumbnail_html`.
127
  * Fixed two small (and rare) warnings
128
  * Added translation domain
129
 
 
 
 
130
  == Upgrade Notice ==
131
 
132
  = 1.0 =
2
  Contributors: janwoostendorp
3
  Tags: media, image
4
  Requires at least: 3.5
5
+ Tested up to: 4.8
6
+ Stable tag: 1.6
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
127
  * Fixed two small (and rare) warnings
128
  * Added translation domain
129
 
130
+ = 1.6 =
131
+ * On of the last fixes didn't account for all situations.
132
+
133
  == Upgrade Notice ==
134
 
135
  = 1.0 =
set-default-featured-image.php CHANGED
@@ -3,7 +3,7 @@
3
  * plugin name: Default featured image
4
  * Plugin URI: http://wordpress.org/extend/plugins/default-featured-image/
5
  * Description: Allows users to select a default feartured image in the media settings
6
- * Version: 1.5
7
  * Author: Jan Willem Oostendorp
8
  * License: GPLv2 or later
9
  * Text Domain: default-featured-image
@@ -201,10 +201,6 @@ class default_featured_image
201
  function show_dfi( $html, $post_id, $post_thumbnail_id, $size, $attr ) {
202
  $default_thumbnail_id = get_option( 'dfi_image_id' ); //select the default thumb
203
 
204
- if ( is_array($size)) {
205
- $size = 'size-' . implode( 'x', $size);
206
- }
207
-
208
  // if an image is set return that image
209
  if ( $default_thumbnail_id != $post_thumbnail_id )
210
  return $html;
@@ -212,8 +208,12 @@ class default_featured_image
212
  if (isset($attr['class']) ) {
213
  $attr['class'] .= " default-featured-img";
214
  } else {
 
 
 
 
215
  //attachment-$size is a default class `wp_get_attachment_image` would otherwise add. It won't add it if there are classes already there
216
- $attr = array ('class' => "attachment-{$size} default-featured-img");
217
  }
218
 
219
  $html = wp_get_attachment_image( $default_thumbnail_id, $size, false, $attr );
3
  * plugin name: Default featured image
4
  * Plugin URI: http://wordpress.org/extend/plugins/default-featured-image/
5
  * Description: Allows users to select a default feartured image in the media settings
6
+ * Version: 1.6
7
  * Author: Jan Willem Oostendorp
8
  * License: GPLv2 or later
9
  * Text Domain: default-featured-image
201
  function show_dfi( $html, $post_id, $post_thumbnail_id, $size, $attr ) {
202
  $default_thumbnail_id = get_option( 'dfi_image_id' ); //select the default thumb
203
 
 
 
 
 
204
  // if an image is set return that image
205
  if ( $default_thumbnail_id != $post_thumbnail_id )
206
  return $html;
208
  if (isset($attr['class']) ) {
209
  $attr['class'] .= " default-featured-img";
210
  } else {
211
+ $size_class = $size;
212
+ if ( is_array( $size_class )) {
213
+ $size_class = 'size-' . implode( 'x', $size_class);
214
+ }
215
  //attachment-$size is a default class `wp_get_attachment_image` would otherwise add. It won't add it if there are classes already there
216
+ $attr = array ('class' => "attachment-{$size_class} default-featured-img");
217
  }
218
 
219
  $html = wp_get_attachment_image( $default_thumbnail_id, $size, false, $attr );