Image Widget - Version 3.3.7

Version Description

  • Add filters so that people can more easily adjust the output of the widget as per @TCBarrett's request.
Download this release

Release Info

Developer peterchester
Plugin Icon 128x128 Image Widget
Version 3.3.7
Comparing to
See all releases

Code changes from version 3.3.6 to 3.3.7

Files changed (3) hide show
  1. image-widget.php +11 -2
  2. readme.txt +52 -1
  3. views/widget.php +3 -7
image-widget.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Image Widget
4
  Plugin URI: http://wordpress.org/extend/plugins/image-widget/
5
  Description: Simple image widget that uses native WordPress upload thickbox to add image widgets to your site.
6
  Author: Modern Tribe, Inc.
7
- Version: 3.3.6
8
  Author URI: http://tri.be
9
  */
10
 
@@ -197,7 +197,16 @@ class Tribe_Image_Widget extends WP_Widget {
197
  extract( $instance );
198
  if ( !empty( $imageurl ) ) {
199
  $title = apply_filters( 'widget_title', empty( $title ) ? '' : $title );
200
- $imageurl = apply_filters( 'image_widget_image_url', $imageurl, $args, $instance );
 
 
 
 
 
 
 
 
 
201
  include( $this->getTemplateHierarchy( 'widget' ) );
202
  }
203
  }
4
  Plugin URI: http://wordpress.org/extend/plugins/image-widget/
5
  Description: Simple image widget that uses native WordPress upload thickbox to add image widgets to your site.
6
  Author: Modern Tribe, Inc.
7
+ Version: 3.3.7
8
  Author URI: http://tri.be
9
  */
10
 
197
  extract( $instance );
198
  if ( !empty( $imageurl ) ) {
199
  $title = apply_filters( 'widget_title', empty( $title ) ? '' : $title );
200
+ $description = apply_filters( 'widget_text', $description, $args, $instance );
201
+ $imageurl = apply_filters( 'image_widget_image_url', esc_url( $imageurl ), $args, $instance );
202
+ if ( $link ) {
203
+ $link = apply_filters( 'image_widget_image_link', esc_url( $link ), $args, $instance );
204
+ $linktarget = apply_filters( 'image_widget_image_link_target', esc_attr( $linktarget ), $args, $instance );
205
+ }
206
+ $width = apply_filters( 'image_widget_image_width', $width, $args, $instance );
207
+ $height = apply_filters( 'image_widget_image_height', $height, $args, $instance );
208
+ $align = apply_filters( 'image_widget_image_align', esc_attr( $align ), $args, $instance );
209
+ $alt = apply_filters( 'image_widget_image_alt', esc_attr( $alt ), $args, $instance );
210
  include( $this->getTemplateHierarchy( 'widget' ) );
211
  }
212
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: widget, image, ad, banner, simple, upload, sidebar, admin, thickbox, resize, french, german, japanese, portuguese, romanian, swedish, dutch, czech, ssl, https, widget-only
5
  Requires at least: 3.0
6
  Tested up to: 3.4.1
7
- Stable tag: 3.3.6
8
 
9
  == Description ==
10
 
@@ -72,8 +72,59 @@ function my_template_filter($template) {
72
  return get_template_directory() . '/my-custom-templates/my-custom-name.php';
73
  }`
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  == Changelog ==
76
 
 
 
 
 
77
  = 3.3.6 =
78
 
79
  * Czech translation courtesy of Vladislav Musilek at blogísek (http://blog.musilda.cz).
4
  Tags: widget, image, ad, banner, simple, upload, sidebar, admin, thickbox, resize, french, german, japanese, portuguese, romanian, swedish, dutch, czech, ssl, https, widget-only
5
  Requires at least: 3.0
6
  Tested up to: 3.4.1
7
+ Stable tag: 3.3.7
8
 
9
  == Description ==
10
 
72
  return get_template_directory() . '/my-custom-templates/my-custom-name.php';
73
  }`
74
 
75
+ = Filters =
76
+
77
+ There are a number of filters in the code that will allow you to override data as you see fit. The best way to learn what filters are available is always by simply searching the code for 'apply_filters'. But all the same, here are a few of the more essential filters:
78
+
79
+ *widget_title*
80
+
81
+ This is actually a pretty typical filter in widgets and is applied to the widget title.
82
+
83
+ *widget_text*
84
+
85
+ Another very typical widget filter that is applied to the description body text. This filter also takes 2 additional arguments for $args and $instance so that you can learn more about the specific widget instance in the process of filtering the content.
86
+
87
+ *image_widget_image_url*
88
+
89
+ Filters the url of the image displayed in the widget.
90
+ Accepts additional $args and $instance arguments.
91
+
92
+ *image_widget_image_link*
93
+
94
+ Filters the url that the image links to.
95
+ Accepts additional $args and $instance arguments.
96
+
97
+ *image_widget_image_link_target*
98
+
99
+ Filters the link target of the image link.
100
+ Accepts additional $args and $instance arguments.
101
+
102
+ *image_widget_image_width*
103
+
104
+ Filters the display width of the image. Hint: override this to use this in responsive designs :)
105
+ Accepts additional $args and $instance arguments.
106
+
107
+ *image_widget_image_height*
108
+
109
+ Filters the display height of the image.
110
+ Accepts additional $args and $instance arguments.
111
+
112
+ *image_widget_image_align*
113
+
114
+ Filters the display alignment of the image.
115
+ Accepts additional $args and $instance arguments.
116
+
117
+ *image_widget_image_alt*
118
+
119
+ Filters the alt text of the image.
120
+ Accepts additional $args and $instance arguments.
121
+
122
  == Changelog ==
123
 
124
+ = 3.3.7 =
125
+
126
+ * Add filters so that people can more easily adjust the output of the widget as per @TCBarrett's request.
127
+
128
  = 3.3.6 =
129
 
130
  * Czech translation courtesy of Vladislav Musilek at blogísek (http://blog.musilda.cz).
views/widget.php CHANGED
@@ -12,10 +12,10 @@ echo $before_widget;
12
  if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }
13
  if ( !empty( $imageurl ) ) {
14
  if ( $link ) {
15
- echo '<a class="'.$this->widget_options['classname'].'-image-link" href="'.esc_url($link).'" target="'.esc_attr($linktarget).'">';
16
  }
17
  if ( $imageurl ) {
18
- echo '<img src="'.esc_url($imageurl).'" style="';
19
  if ( !empty( $width ) && is_numeric( $width ) ) {
20
  echo "max-width: {$width}px;";
21
  }
@@ -24,14 +24,11 @@ if ( !empty( $imageurl ) ) {
24
  }
25
  echo "\"";
26
  if ( !empty( $align ) && $align != 'none' ) {
27
- $align = esc_attr($align);
28
  echo " class=\"align{$align}\"";
29
  }
30
  if ( !empty( $alt ) ) {
31
- $alt = esc_attr($alt);
32
  echo " alt=\"{$alt}\"";
33
  } else {
34
- $title = esc_attr($title);
35
  echo " alt=\"{$title}\"";
36
  }
37
  echo " />";
@@ -40,9 +37,8 @@ if ( !empty( $imageurl ) ) {
40
  if ( $link ) { echo '</a>'; }
41
  }
42
  if ( !empty( $description ) ) {
43
- $text = apply_filters( 'widget_text', $description, $args, $instance );
44
  echo '<div class="'.$this->widget_options['classname'].'-description" >';
45
- echo wpautop( $text );
46
  echo "</div>";
47
  }
48
  echo $after_widget;
12
  if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }
13
  if ( !empty( $imageurl ) ) {
14
  if ( $link ) {
15
+ echo '<a class="'.$this->widget_options['classname'].'-image-link" href="'.$link.'" target="'.$linktarget.'">';
16
  }
17
  if ( $imageurl ) {
18
+ echo '<img src="'.$imageurl.'" style="';
19
  if ( !empty( $width ) && is_numeric( $width ) ) {
20
  echo "max-width: {$width}px;";
21
  }
24
  }
25
  echo "\"";
26
  if ( !empty( $align ) && $align != 'none' ) {
 
27
  echo " class=\"align{$align}\"";
28
  }
29
  if ( !empty( $alt ) ) {
 
30
  echo " alt=\"{$alt}\"";
31
  } else {
 
32
  echo " alt=\"{$title}\"";
33
  }
34
  echo " />";
37
  if ( $link ) { echo '</a>'; }
38
  }
39
  if ( !empty( $description ) ) {
 
40
  echo '<div class="'.$this->widget_options['classname'].'-description" >';
41
+ echo wpautop( $description );
42
  echo "</div>";
43
  }
44
  echo $after_widget;