Image Widget - Version 4.0

Version Description

  • Significant upgrades to support the new WordPress media manager (Thank you @kyleunzicker, @dancameron, @dudekpj, @JakePT)
  • Significant improvements the administrative user interface.
  • Abstracted support for older versions of WordPress so that that we don't break old versions with this upgrade (Though there's no reason you should up grade this widget and NOT your WP install! You should always keep WordPress core up to date!)
  • Added 'image_widget_link_attributes' filter to easily process link attributes and to default to having the link 'title' be the 'alt' or 'title' content. (Thank you @ZeroGravity, @pixelyzed, and @javiandgo)
  • Updated Translations ** Swedish (Tomas Lindhoff tomas@xhost.se) ** Dutch (Presis contact@presis.nl) ** Italian (@maxgx)
Download this release

Release Info

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

Code changes from version 3.3.7 to 4.0

Files changed (40) hide show
  1. image-widget.php +274 -190
  2. lang/image-widget-en_EN.mo +0 -0
  3. lang/image-widget-en_EN.po +138 -0
  4. lang/image-widget-it_IT.mo +0 -0
  5. lang/image-widget-it_IT.po +148 -0
  6. lang/image-widget-nl_NL.mo +0 -0
  7. lang/image-widget-nl_NL.po +144 -0
  8. lang/image-widget-sv_SE.mo +0 -0
  9. lang/image-widget-sv_SE.po +144 -0
  10. lang/{image_widget-cs_CZ.mo → old/image_widget-cs_CZ.mo} +0 -0
  11. lang/{image_widget-cs_CZ.po → old/image_widget-cs_CZ.po} +0 -0
  12. lang/{image_widget-de_DE.mo → old/image_widget-de_DE.mo} +0 -0
  13. lang/{image_widget-de_DE.po → old/image_widget-de_DE.po} +0 -0
  14. lang/{image_widget-fr_FR.mo → old/image_widget-fr_FR.mo} +0 -0
  15. lang/{image_widget-fr_FR.po → old/image_widget-fr_FR.po} +0 -0
  16. lang/old/image_widget-it_IT.mo +0 -0
  17. lang/old/image_widget-it_IT.po +97 -0
  18. lang/{image_widget-ja.mo → old/image_widget-ja.mo} +0 -0
  19. lang/{image_widget-ja.po → old/image_widget-ja.po} +0 -0
  20. lang/{image_widget-nl_NL.mo → old/image_widget-nl_NL.mo} +0 -0
  21. lang/{image_widget-nl_NL.po → old/image_widget-nl_NL.po} +0 -0
  22. lang/{image_widget-pl_PL.mo → old/image_widget-pl_PL.mo} +0 -0
  23. lang/{image_widget-pl_PL.po → old/image_widget-pl_PL.po} +0 -0
  24. lang/{image_widget-pt_BR.mo → old/image_widget-pt_BR.mo} +0 -0
  25. lang/{image_widget-pt_BR.po → old/image_widget-pt_BR.po} +0 -0
  26. lang/{image_widget-ro_RO.mo → old/image_widget-ro_RO.mo} +0 -0
  27. lang/{image_widget-ro_RO.po → old/image_widget-ro_RO.po} +0 -0
  28. lang/{image_widget-sv_SE.mo → old/image_widget-sv_SE.mo} +0 -0
  29. lang/{image_widget-sv_SE.po → old/image_widget-sv_SE.po} +0 -0
  30. lib/ImageWidgetDeprecated.php +202 -0
  31. readme.txt +71 -24
  32. resources/js/image-widget.deprecated.js +123 -0
  33. resources/js/{image-widget-upload-fixer.js → image-widget.deprecated.upload-fixer.js} +0 -0
  34. resources/js/image-widget.js +106 -121
  35. screenshot-1.png +0 -0
  36. screenshot-2.png +0 -0
  37. screenshot-3.png +0 -0
  38. views/widget-admin.deprecated.php +50 -0
  39. views/widget-admin.php +66 -50
  40. views/widget.php +3 -25
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.7
8
  Author URI: http://tri.be
9
  */
10
 
@@ -23,190 +23,87 @@ add_action('widgets_init', 'tribe_load_image_widget');
23
  **/
24
  class Tribe_Image_Widget extends WP_Widget {
25
 
 
 
 
 
26
  /**
27
  * Tribe Image Widget constructor
28
  *
29
- * @author Modern Tribe, Inc. (Peter Chester)
30
  */
31
  function Tribe_Image_Widget() {
32
- $this->loadPluginTextDomain();
33
  $widget_ops = array( 'classname' => 'widget_sp_image', 'description' => __( 'Showcase a single image with a Title, URL, and a Description', 'image_widget' ) );
34
  $control_ops = array( 'id_base' => 'widget_sp_image' );
35
  $this->WP_Widget('widget_sp_image', __('Image Widget', 'image_widget'), $widget_ops, $control_ops);
36
- add_action( 'admin_init', array( $this, 'admin_setup' ) );
37
- }
38
-
39
- function admin_setup() {
40
- global $pagenow;
41
- if ( 'widgets.php' == $pagenow ) {
42
- wp_enqueue_style( 'thickbox' );
43
- wp_enqueue_script( 'tribe-image-widget', plugins_url('resources/js/image-widget.js', __FILE__), array('thickbox'), FALSE, TRUE );
44
- add_action( 'admin_head-widgets.php', array( $this, 'admin_head' ) );
45
- }
46
- elseif ( 'media-upload.php' == $pagenow || 'async-upload.php' == $pagenow ) {
47
- wp_enqueue_script( 'tribe-image-widget-fix-uploader', plugins_url('resources/js/image-widget-upload-fixer.js', __FILE__), array('jquery'), FALSE, TRUE );
48
- add_filter( 'image_send_to_editor', array( $this,'image_send_to_editor'), 1, 8 );
49
- add_filter( 'gettext', array( $this, 'replace_text_in_thickbox' ), 1, 3 );
50
- add_filter( 'media_upload_tabs', array( $this, 'media_upload_tabs' ) );
51
- add_filter( 'image_widget_image_url', array( $this, 'https_cleanup' ) );
52
  }
53
- $this->fix_async_upload_image();
54
- }
55
 
56
- function fix_async_upload_image() {
57
- if(isset($_REQUEST['attachment_id'])) {
58
- $id = (int) $_REQUEST['attachment_id'];
59
- $GLOBALS['post'] = get_post( $id );
60
- }
61
- }
62
 
63
- function loadPluginTextDomain() {
64
- load_plugin_textdomain( 'image_widget', false, trailingslashit(basename(dirname(__FILE__))) . 'lang/');
65
  }
66
 
67
  /**
68
- * Retrieve resized image URL
69
- *
70
- * @param int $id Post ID or Attachment ID
71
- * @param int $width desired width of image (optional)
72
- * @param int $height desired height of image (optional)
73
- * @return string URL
74
- * @author Modern Tribe, Inc. (Peter Chester)
75
  */
76
- function get_image_url( $id, $width=false, $height=false ) {
77
-
78
- /**/
79
- // Get attachment and resize but return attachment path (needs to return url)
80
- $attachment = wp_get_attachment_metadata( $id );
81
- $attachment_url = wp_get_attachment_url( $id );
82
- if (isset($attachment_url)) {
83
- if ($width && $height) {
84
- $uploads = wp_upload_dir();
85
- $imgpath = $uploads['basedir'].'/'.$attachment['file'];
86
- if (WP_DEBUG) {
87
- error_log(__CLASS__.'->'.__FUNCTION__.'() $imgpath = '.$imgpath);
88
- }
89
- $image = image_resize( $imgpath, $width, $height );
90
- if ( $image && !is_wp_error( $image ) ) {
91
- $image = path_join( dirname($attachment_url), basename($image) );
92
- } else {
93
- $image = $attachment_url;
94
- }
95
- } else {
96
- $image = $attachment_url;
97
- }
98
- if (isset($image)) {
99
- return $image;
100
- }
101
- }
102
  }
103
 
104
  /**
105
- * Test context to see if the uploader is being used for the image widget or for other regular uploads
106
- *
107
- * @author Modern Tribe, Inc. (Peter Chester)
108
  */
109
- function is_sp_widget_context() {
110
- if ( isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'],$this->id_base) !== false ) {
111
- return true;
112
- } elseif ( isset($_REQUEST['_wp_http_referer']) && strpos($_REQUEST['_wp_http_referer'],$this->id_base) !== false ) {
113
- return true;
114
- } elseif ( isset($_REQUEST['widget_id']) && strpos($_REQUEST['widget_id'],$this->id_base) !== false ) {
115
- return true;
116
- }
117
- return false;
118
- }
119
-
120
- /**
121
- * Somewhat hacky way of replacing "Insert into Post" with "Insert into Widget"
122
- *
123
- * @param string $translated_text text that has already been translated (normally passed straight through)
124
- * @param string $source_text text as it is in the code
125
- * @param string $domain domain of the text
126
- * @author Modern Tribe, Inc. (Peter Chester)
127
- */
128
- function replace_text_in_thickbox($translated_text, $source_text, $domain) {
129
- if ( $this->is_sp_widget_context() ) {
130
- if ('Insert into Post' == $source_text) {
131
- return __('Insert Into Widget', 'image_widget' );
132
- }
133
- }
134
- return $translated_text;
135
- }
136
-
137
- /**
138
- * Filter image_end_to_editor results
139
- *
140
- * @param string $html
141
- * @param int $id
142
- * @param string $alt
143
- * @param string $title
144
- * @param string $align
145
- * @param string $url
146
- * @param array $size
147
- * @return string javascript array of attachment url and id or just the url
148
- * @author Modern Tribe, Inc. (Peter Chester)
149
- */
150
- function image_send_to_editor( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ) {
151
- // Normally, media uploader return an HTML string (in this case, typically a complete image tag surrounded by a caption).
152
- // Don't change that; instead, send custom javascript variables back to opener.
153
- // Check that this is for the widget. Shouldn't hurt anything if it runs, but let's do it needlessly.
154
- if ( $this->is_sp_widget_context() ) {
155
- if ($alt=='') $alt = $title;
156
- ?>
157
- <script type="text/javascript">
158
- // send image variables back to opener
159
- var win = window.dialogArguments || opener || parent || top;
160
- win.IW_html = '<?php echo addslashes($html); ?>';
161
- win.IW_img_id = '<?php echo $id; ?>';
162
- win.IW_alt = '<?php echo addslashes($alt); ?>';
163
- win.IW_caption = '<?php echo addslashes($caption); ?>';
164
- win.IW_title = '<?php echo addslashes($title); ?>';
165
- win.IW_align = '<?php echo esc_attr($align); ?>';
166
- win.IW_url = '<?php echo esc_url($url); ?>';
167
- win.IW_size = '<?php echo esc_attr($size); ?>';
168
- </script>
169
- <?php
170
- }
171
- return $html;
172
- }
173
 
174
- /**
175
- * Remove from url tab until that functionality is added to widgets.
176
- *
177
- * @param array $tabs
178
- * @author Modern Tribe, Inc. (Peter Chester)
179
- */
180
- function media_upload_tabs($tabs) {
181
- if ( $this->is_sp_widget_context() ) {
182
- unset($tabs['type_url']);
183
- }
184
- return $tabs;
185
  }
186
 
187
-
188
  /**
189
  * Widget frontend output
190
  *
191
  * @param array $args
192
  * @param array $instance
193
- * @author Modern Tribe, Inc. (Peter Chester)
194
  */
195
  function widget( $args, $instance ) {
196
  extract( $args );
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
  }
@@ -217,12 +114,13 @@ class Tribe_Image_Widget extends WP_Widget {
217
  * @param object $new_instance Widget Instance
218
  * @param object $old_instance Widget Instance
219
  * @return object
220
- * @author Modern Tribe, Inc. (Peter Chester)
221
  */
222
  function update( $new_instance, $old_instance ) {
223
  $instance = $old_instance;
 
224
  $instance['title'] = strip_tags($new_instance['title']);
225
- if ( isset($new_instance['description']) ) {
226
  if ( current_user_can('unfiltered_html') ) {
227
  $instance['description'] = $new_instance['description'];
228
  } else {
@@ -230,14 +128,28 @@ class Tribe_Image_Widget extends WP_Widget {
230
  }
231
  }
232
  $instance['link'] = $new_instance['link'];
233
- $instance['image'] = $new_instance['image'];
234
- $instance['imageurl'] = $this->get_image_url($new_instance['image'],$new_instance['width'],$new_instance['height']); // image resizing not working right now
235
  $instance['linktarget'] = $new_instance['linktarget'];
236
- $instance['width'] = $new_instance['width'];
237
- $instance['height'] = $new_instance['height'];
 
 
 
238
  $instance['align'] = $new_instance['align'];
239
  $instance['alt'] = $new_instance['alt'];
240
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  return $instance;
242
  }
243
 
@@ -245,56 +157,198 @@ class Tribe_Image_Widget extends WP_Widget {
245
  * Form UI
246
  *
247
  * @param object $instance Widget Instance
248
- * @author Modern Tribe, Inc. (Peter Chester)
249
  */
250
  function form( $instance ) {
 
 
 
 
 
 
 
251
 
252
- $instance = wp_parse_args( (array) $instance, array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  'title' => '',
254
  'description' => '',
255
  'link' => '',
256
  'linktarget' => '',
257
- 'width' => '',
258
- 'height' => '',
259
- 'image' => '',
260
- 'imageurl' => '',
261
- 'align' => '',
262
- 'alt' => ''
263
- ) );
264
- include( $this->getTemplateHierarchy( 'widget-admin' ) );
 
 
 
 
 
 
265
  }
266
 
267
  /**
268
- * Admin header css
269
  *
270
- * @author Modern Tribe, Inc. (Peter Chester)
 
 
271
  */
272
- function admin_head() {
273
- ?>
274
- <style type="text/css">
275
- .aligncenter {
276
- display: block;
277
- margin-left: auto;
278
- margin-right: auto;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  }
280
- </style>
281
- <?php
 
 
 
 
 
 
 
 
282
  }
283
 
284
  /**
285
- * Adjust the image url on output to account for SSL.
286
  *
287
- * @param string $imageurl
288
- * @return string $imageurl
289
- * @author Modern Tribe, Inc. (Peter Chester)
290
  */
291
- function https_cleanup( $imageurl = '' ) {
292
- if( isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on" ) {
293
- $imageurl = str_replace('http://', 'https://', $imageurl);
 
 
294
  } else {
295
- $imageurl = str_replace('https://', 'http://', $imageurl);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
  }
297
- return $imageurl;
298
  }
299
 
300
  /**
@@ -319,4 +373,34 @@ class Tribe_Image_Widget extends WP_Widget {
319
  }
320
  return apply_filters( 'sp_template_image-widget_'.$template, $file);
321
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
322
  }
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: 4.0
8
  Author URI: http://tri.be
9
  */
10
 
23
  **/
24
  class Tribe_Image_Widget extends WP_Widget {
25
 
26
+ const VERSION = '4.1';
27
+
28
+ const CUSTOM_IMAGE_SIZE_SLUG = 'tribe_image_widget_custom';
29
+
30
  /**
31
  * Tribe Image Widget constructor
32
  *
33
+ * @author Modern Tribe, Inc.
34
  */
35
  function Tribe_Image_Widget() {
36
+ load_plugin_textdomain( 'image_widget', false, trailingslashit(basename(dirname(__FILE__))) . 'lang/');
37
  $widget_ops = array( 'classname' => 'widget_sp_image', 'description' => __( 'Showcase a single image with a Title, URL, and a Description', 'image_widget' ) );
38
  $control_ops = array( 'id_base' => 'widget_sp_image' );
39
  $this->WP_Widget('widget_sp_image', __('Image Widget', 'image_widget'), $widget_ops, $control_ops);
40
+ if ( $this->use_old_uploader() ) {
41
+ require_once( 'lib/ImageWidgetDeprecated.php' );
42
+ new ImageWidgetDeprecated( $this );
43
+ } else {
44
+ add_action( 'sidebar_admin_setup', array( $this, 'admin_setup' ) );
 
 
 
 
 
 
 
 
 
 
 
45
  }
46
+ add_action( 'admin_head-widgets.php', array( $this, 'admin_head' ) );
 
47
 
48
+ add_action( 'plugin_row_meta', array( $this, 'plugin_row_meta' ),10 ,2 );
 
 
 
 
 
49
 
50
+ add_action( 'admin_notices', array( $this, 'post_upgrade_nag') );
51
+ add_action( 'network_admin_notices', array( $this, 'post_upgrade_nag') );
52
  }
53
 
54
  /**
55
+ * Test to see if this version of WordPress supports the new image manager.
56
+ * @return bool true if the current version of WordPress does NOT support the current image management tech.
 
 
 
 
 
57
  */
58
+ private function use_old_uploader() {
59
+ if ( defined( 'IMAGE_WIDGET_COMPATIBILITY_TEST' ) ) return true;
60
+ return !function_exists('wp_enqueue_media');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
62
 
63
  /**
64
+ * Enqueue all the javascript.
 
 
65
  */
66
+ function admin_setup() {
67
+ wp_enqueue_media();
68
+ wp_enqueue_script( 'tribe-image-widget', plugins_url('resources/js/image-widget.js', __FILE__), array( 'jquery', 'media-upload', 'media-views' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
+ wp_localize_script( 'tribe-image-widget', 'TribeImageWidget', array(
71
+ 'frame_title' => __( 'Select an Image', 'image_widget' ),
72
+ 'button_title' => __( 'Insert Into Widget', 'image_widget' ),
73
+ ) );
 
 
 
 
 
 
 
74
  }
75
 
 
76
  /**
77
  * Widget frontend output
78
  *
79
  * @param array $args
80
  * @param array $instance
81
+ * @author Modern Tribe, Inc.
82
  */
83
  function widget( $args, $instance ) {
84
  extract( $args );
85
+ $instance = wp_parse_args( (array) $instance, self::get_defaults() );
86
+ if ( !empty( $instance['imageurl'] ) || !empty( $instance['attachment_id'] ) ) {
87
+
88
+ $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'] );
89
+ $instance['description'] = apply_filters( 'widget_text', $instance['description'], $args, $instance );
90
+ $instance['link'] = apply_filters( 'image_widget_image_link', esc_url( $instance['link'] ), $args, $instance );
91
+ $instance['linktarget'] = apply_filters( 'image_widget_image_link_target', esc_attr( $instance['linktarget'] ), $args, $instance );
92
+ $instance['width'] = apply_filters( 'image_widget_image_width', abs( $instance['width'] ), $args, $instance );
93
+ $instance['height'] = apply_filters( 'image_widget_image_height', abs( $instance['height'] ), $args, $instance );
94
+ $instance['align'] = apply_filters( 'image_widget_image_align', esc_attr( $instance['align'] ), $args, $instance );
95
+ $instance['alt'] = apply_filters( 'image_widget_image_alt', esc_attr( $instance['alt'] ), $args, $instance );
96
+
97
+ if ( !defined( 'IMAGE_WIDGET_COMPATIBILITY_TEST' ) ) {
98
+ $instance['attachment_id'] = ( $instance['attachment_id'] > 0 ) ? $instance['attachment_id'] : $instance['image'];
99
+ $instance['attachment_id'] = apply_filters( 'image_widget_image_attachment_id', abs( $instance['attachment_id'] ), $args, $instance );
100
+ $instance['size'] = apply_filters( 'image_widget_image_size', esc_attr( $instance['size'] ), $args, $instance );
101
  }
102
+ $instance['imageurl'] = apply_filters( 'image_widget_image_url', esc_url( $instance['imageurl'] ), $args, $instance );
103
+
104
+ // No longer using extracted vars. This is here for backwards compatibility.
105
+ extract( $instance );
106
+
107
  include( $this->getTemplateHierarchy( 'widget' ) );
108
  }
109
  }
114
  * @param object $new_instance Widget Instance
115
  * @param object $old_instance Widget Instance
116
  * @return object
117
+ * @author Modern Tribe, Inc.
118
  */
119
  function update( $new_instance, $old_instance ) {
120
  $instance = $old_instance;
121
+ $new_instance = wp_parse_args( (array) $new_instance, self::get_defaults() );
122
  $instance['title'] = strip_tags($new_instance['title']);
123
+ if ( !empty( $new_instance['description'] ) ) {
124
  if ( current_user_can('unfiltered_html') ) {
125
  $instance['description'] = $new_instance['description'];
126
  } else {
128
  }
129
  }
130
  $instance['link'] = $new_instance['link'];
 
 
131
  $instance['linktarget'] = $new_instance['linktarget'];
132
+ $instance['width'] = abs( $new_instance['width'] );
133
+ $instance['height'] =abs( $new_instance['height'] );
134
+ if ( !defined( 'IMAGE_WIDGET_COMPATIBILITY_TEST' ) ) {
135
+ $instance['size'] = $new_instance['size'];
136
+ }
137
  $instance['align'] = $new_instance['align'];
138
  $instance['alt'] = $new_instance['alt'];
139
 
140
+ // Reverse compatibility with $image, now called $attachement_id
141
+ if ( !defined( 'IMAGE_WIDGET_COMPATIBILITY_TEST' ) && $new_instance['attachment_id'] > 0 ) {
142
+ $instance['attachment_id'] = abs( $new_instance['attachment_id'] );
143
+ } elseif ( $new_instance['image'] > 0 ) {
144
+ $instance['attachment_id'] = $instance['image'] = abs( $new_instance['image'] );
145
+ if ( class_exists('ImageWidgetDeprecated') ) {
146
+ $instance['imageurl'] = ImageWidgetDeprecated::get_image_url( $instance['image'], $instance['width'], $instance['height'] ); // image resizing not working right now
147
+ }
148
+ }
149
+ $instance['imageurl'] = $new_instance['imageurl']; // deprecated
150
+
151
+ $instance['aspect_ratio'] = $this->get_image_aspect_ratio( $instance );
152
+
153
  return $instance;
154
  }
155
 
157
  * Form UI
158
  *
159
  * @param object $instance Widget Instance
160
+ * @author Modern Tribe, Inc.
161
  */
162
  function form( $instance ) {
163
+ $instance = wp_parse_args( (array) $instance, self::get_defaults() );
164
+ if ( $this->use_old_uploader() ) {
165
+ include( $this->getTemplateHierarchy( 'widget-admin.deprecated' ) );
166
+ } else {
167
+ include( $this->getTemplateHierarchy( 'widget-admin' ) );
168
+ }
169
+ }
170
 
171
+ /**
172
+ * Admin header css
173
+ *
174
+ * @author Modern Tribe, Inc.
175
+ */
176
+ function admin_head() {
177
+ ?>
178
+ <style type="text/css">
179
+ .uploader input.button {
180
+ width: 100%;
181
+ height: 34px;
182
+ line-height: 33px;
183
+ }
184
+ .tribe_preview .aligncenter {
185
+ display: block;
186
+ margin-left: auto !important;
187
+ margin-right: auto !important;
188
+ }
189
+ .tribe_preview {
190
+ overflow: hidden;
191
+ max-height: 300px;
192
+ }
193
+ .tribe_preview img {
194
+ margin: 10px 0;
195
+ }
196
+ </style>
197
+ <?php
198
+ }
199
+
200
+ /**
201
+ * Render an array of default values.
202
+ *
203
+ * @return array default values
204
+ */
205
+ private static function get_defaults() {
206
+
207
+ $defaults = array(
208
  'title' => '',
209
  'description' => '',
210
  'link' => '',
211
  'linktarget' => '',
212
+ 'width' => 0,
213
+ 'height' => 0,
214
+ 'image' => 0, // reverse compatible - now attachement_id
215
+ 'imageurl' => '', // reverse compatible.
216
+ 'align' => 'none',
217
+ 'alt' => '',
218
+ );
219
+
220
+ if ( !defined( 'IMAGE_WIDGET_COMPATIBILITY_TEST' ) ) {
221
+ $defaults['size'] = self::CUSTOM_IMAGE_SIZE_SLUG;
222
+ $defaults['attachment_id'] = 0;
223
+ }
224
+
225
+ return $defaults;
226
  }
227
 
228
  /**
229
+ * Render the image html output.
230
  *
231
+ * @param array $instance
232
+ * @param bool $include_link will only render the link if this is set to true. Otherwise link is ignored.
233
+ * @return string image html
234
  */
235
+ private function get_image_html( $instance, $include_link = true ) {
236
+
237
+ // Backwards compatible image display.
238
+ if ( $instance['attachment_id'] == 0 && $instance['image'] > 0 ) {
239
+ $instance['attachment_id'] = $instance['image'];
240
+ }
241
+
242
+ $output = '';
243
+
244
+ if ( $include_link && !empty( $instance['link'] ) ) {
245
+ $attr = array(
246
+ 'href' => $instance['link'],
247
+ 'target' => $instance['linktarget'],
248
+ 'class' => $this->widget_options['classname'].'-image-link',
249
+ 'title' => ( !empty( $instance['alt'] ) ) ? $instance['alt'] : $instance['title'],
250
+ );
251
+ $attr = apply_filters('image_widget_link_attributes', $attr, $instance );
252
+ $attr = array_map( 'esc_attr', $attr );
253
+ $output = '<a';
254
+ foreach ( $attr as $name => $value ) {
255
+ $output .= sprintf( ' %s="%s"', $name, $value );
256
+ }
257
+ $output .= '>';
258
+ }
259
+
260
+ $size = $this->get_image_size( $instance );
261
+ if ( is_array( $size ) ) {
262
+ $instance['width'] = $size[0];
263
+ $instance['height'] = $size[1];
264
+ } elseif ( !empty( $instance['attachment_id'] ) ) {
265
+ //$instance['width'] = $instance['height'] = 0;
266
+ $image_details = wp_get_attachment_image_src( $instance['attachment_id'], $size );
267
+ if ($image_details) {
268
+ $instance['imageurl'] = $image_details[0];
269
+ $instance['width'] = $image_details[1];
270
+ $instance['height'] = $image_details[2];
271
+ }
272
+ }
273
+ $instance['width'] = abs( $instance['width'] );
274
+ $instance['height'] = abs( $instance['height'] );
275
+
276
+ $attr = array();
277
+ $attr['alt'] = $instance['title'];
278
+ if (is_array($size)) {
279
+ $attr['class'] = 'attachment-'.join('x',$size);
280
+ } else {
281
+ $attr['class'] = 'attachment-'.$size;
282
+ }
283
+ $attr['style'] = '';
284
+ if (!empty($instance['width'])) {
285
+ $attr['style'] .= "max-width: {$instance['width']}px;";
286
+ }
287
+ if (!empty($instance['height'])) {
288
+ $attr['style'] .= "max-height: {$instance['height']}px;";
289
+ }
290
+ if (!empty($instance['align']) && $instance['align'] != 'none') {
291
+ $attr['class'] .= " align{$instance['align']}";
292
+ }
293
+ $attr = apply_filters( 'image_widget_image_attributes', $attr, $instance );
294
+
295
+ // If there is an imageurl, use it to render the image. Eventually we should kill this and simply rely on attachment_ids.
296
+ if ( !empty( $instance['imageurl'] ) ) {
297
+ // If all we have is an image src url we can still render an image.
298
+ $attr['src'] = $instance['imageurl'];
299
+ $attr = array_map( 'esc_attr', $attr );
300
+ $hwstring = image_hwstring( $instance['width'], $instance['height'] );
301
+ $output .= rtrim("<img $hwstring");
302
+ foreach ( $attr as $name => $value ) {
303
+ $output .= sprintf( ' %s="%s"', $name, $value );
304
  }
305
+ $output .= ' />';
306
+ } elseif( abs( $instance['attachment_id'] ) > 0 ) {
307
+ $output .= wp_get_attachment_image($instance['attachment_id'], $size, false, $attr);
308
+ }
309
+
310
+ if ( $include_link && !empty( $instance['link'] ) ) {
311
+ $output .= '</a>';
312
+ }
313
+
314
+ return $output;
315
  }
316
 
317
  /**
318
+ * Assesses the image size in case it has not been set or in case there is a mismatch.
319
  *
320
+ * @param $instance
321
+ * @return array|string
 
322
  */
323
+ private function get_image_size( $instance ) {
324
+ if ( !empty( $instance['size'] ) && $instance['size'] != self::CUSTOM_IMAGE_SIZE_SLUG ) {
325
+ $size = $instance['size'];
326
+ } elseif ( isset( $instance['width'] ) && is_numeric($instance['width']) && isset( $instance['height'] ) && is_numeric($instance['height']) ) {
327
+ $size = array(abs($instance['width']),abs($instance['height']));
328
  } else {
329
+ $size = 'full';
330
+ }
331
+ return $size;
332
+ }
333
+
334
+ /**
335
+ * Establish the aspect ratio of the image.
336
+ *
337
+ * @param $instance
338
+ * @return float|number
339
+ */
340
+ private function get_image_aspect_ratio( $instance ) {
341
+ if ( !empty( $instance['aspect_ratio'] ) ) {
342
+ return abs( $instance['aspect_ratio'] );
343
+ } else {
344
+ $attachment_id = ( !empty($instance['attachment_id']) ) ? $instance['attachment_id'] : $instance['image'];
345
+ if ( !empty($attachment_id) ) {
346
+ $image_details = wp_get_attachment_image_src( $attachment_id, 'full' );
347
+ if ($image_details) {
348
+ return ( $image_details[1]/$image_details[2] );
349
+ }
350
+ }
351
  }
 
352
  }
353
 
354
  /**
373
  }
374
  return apply_filters( 'sp_template_image-widget_'.$template, $file);
375
  }
376
+
377
+
378
+ /**
379
+ * Display a thank you nag when the plugin has been upgraded.
380
+ */
381
+ public function post_upgrade_nag() {
382
+ if ( !current_user_can('install_plugins') ) return;
383
+
384
+ $version_key = '_image_widget_version';
385
+ if ( get_site_option( $version_key ) == self::VERSION ) return;
386
+
387
+ $msg = sprintf(__('Thanks for upgrading the Image Widget! If you like this plugin, please consider <a href="%s" target="_blank">rating it</a> and maybe even check out our premium plugins including our <a href="%s" target="_blank">Events Calendar Pro</a>!', 'image-widget'),'http://wordpress.org/extend/plugins/image-widget/?source=image-widget&pos=nag','http://tri.be/wordpress-events-calendar-pro/?source=image-widget&pos=nag');
388
+ echo "<div class='update-nag'>$msg</div>";
389
+
390
+ update_site_option( $version_key, self::VERSION );
391
+ }
392
+
393
+ /**
394
+ * Display an informational section in the plugin admin ui.
395
+ * @param $meta
396
+ * @param $file
397
+ *
398
+ * @return array
399
+ */
400
+ public function plugin_row_meta( $meta, $file ) {
401
+ if ( $file == plugin_basename( dirname(__FILE__).'/image-widget.php' ) ) {
402
+ $meta[] = '<span class="tribe-test">'.sprintf(__('Check out our other <a href="%s" target="_blank">plugins</a> including our <a href="%s" target="_blank">Events Calendar Pro</a>!', 'image-widget'),'http://tri.be/products/?source=image-widget&pos=pluginlist','http://tri.be/wordpress-events-calendar-pro/?source=image-widget&pos=pluginlist').'</span>';
403
+ }
404
+ return $meta;
405
+ }
406
  }
lang/image-widget-en_EN.mo ADDED
Binary file
lang/image-widget-en_EN.po ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Translation of the Image Widget 4.0 WordPress plugin.
2
+ # This file is distributed under the same license as the the Image Widget package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Image Widget\n"
6
+ "POT-Creation-Date: 2013-01-30 23:34-0800\n"
7
+ "PO-Revision-Date: 2013-01-30 23:50-0800\n"
8
+ "Last-Translator: Modern Tribe, Inc. <pro@tri.be>\n"
9
+ "Language-Team: @ModernTribe <pro@tri.be>\n"
10
+ "Language: English\n"
11
+ "MIME-Version: 1.0\n"
12
+ "Content-Type: text/plain; charset=UTF-8\n"
13
+ "Content-Transfer-Encoding: 8bit\n"
14
+ "X-Generator: Poedit 1.5.4\n"
15
+ "X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e\n"
16
+ "X-Poedit-Basepath: .\n"
17
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
+ "X-Poedit-SourceCharset: UTF-8\n"
19
+
20
+ #: image-widget.php:40
21
+ msgid "Showcase a single image with a Title, URL, and a Description"
22
+ msgstr ""
23
+
24
+ #: image-widget.php:42
25
+ msgid "Image Widget"
26
+ msgstr ""
27
+
28
+ #: image-widget.php:74 views/widget-admin.php:13
29
+ msgid "Select an Image"
30
+ msgstr ""
31
+
32
+ #: image-widget.php:75 lib/ImageWidgetDeprecated.php:66
33
+ msgid "Insert Into Widget"
34
+ msgstr ""
35
+
36
+ #: image-widget.php:390
37
+ #, php-format
38
+ msgid ""
39
+ "Thanks for upgrading the Image Widget! If you like this plugin, please "
40
+ "consider <a href=\"%s\" target=\"_blank\">rating it</a> and maybe even check "
41
+ "out our premium plugins including our <a href=\"%s\" target=\"_blank"
42
+ "\">Events Calendar Pro</a>!"
43
+ msgstr ""
44
+
45
+ #: image-widget.php:405
46
+ #, php-format
47
+ msgid ""
48
+ "Check out our other <a href=\"%s\" target=\"_blank\">plugins</a> including "
49
+ "our <a href=\"%s\" target=\"_blank\">Events Calendar Pro</a>!"
50
+ msgstr ""
51
+
52
+ #: views/widget-admin.deprecated.php:10 views/widget-admin.php:23
53
+ msgid "Title"
54
+ msgstr ""
55
+
56
+ #: views/widget-admin.deprecated.php:13
57
+ msgid "Image"
58
+ msgstr ""
59
+
60
+ #: views/widget-admin.deprecated.php:17
61
+ msgid "Change Image"
62
+ msgstr ""
63
+
64
+ #: views/widget-admin.deprecated.php:17
65
+ msgid "Add Image"
66
+ msgstr ""
67
+
68
+ #: views/widget-admin.deprecated.php:25 views/widget-admin.php:29
69
+ msgid "Caption"
70
+ msgstr ""
71
+
72
+ #: views/widget-admin.deprecated.php:28 views/widget-admin.php:32
73
+ msgid "Link"
74
+ msgstr ""
75
+
76
+ #: views/widget-admin.deprecated.php:31 views/widget-admin.php:35
77
+ msgid "Stay in Window"
78
+ msgstr ""
79
+
80
+ #: views/widget-admin.deprecated.php:32 views/widget-admin.php:36
81
+ msgid "Open New Window"
82
+ msgstr ""
83
+
84
+ #: views/widget-admin.deprecated.php:35 views/widget-admin.php:66
85
+ msgid "Width"
86
+ msgstr ""
87
+
88
+ #: views/widget-admin.deprecated.php:38 views/widget-admin.php:69
89
+ msgid "Height"
90
+ msgstr ""
91
+
92
+ #: views/widget-admin.deprecated.php:41 views/widget-admin.php:74
93
+ msgid "Align"
94
+ msgstr ""
95
+
96
+ #: views/widget-admin.deprecated.php:43 views/widget-admin.php:76
97
+ msgid "none"
98
+ msgstr ""
99
+
100
+ #: views/widget-admin.deprecated.php:44 views/widget-admin.php:77
101
+ msgid "left"
102
+ msgstr ""
103
+
104
+ #: views/widget-admin.deprecated.php:45 views/widget-admin.php:78
105
+ msgid "center"
106
+ msgstr ""
107
+
108
+ #: views/widget-admin.deprecated.php:46 views/widget-admin.php:79
109
+ msgid "right"
110
+ msgstr ""
111
+
112
+ #: views/widget-admin.deprecated.php:49 views/widget-admin.php:26
113
+ msgid "Alternate Text"
114
+ msgstr ""
115
+
116
+ #: views/widget-admin.php:44
117
+ msgid "Size"
118
+ msgstr ""
119
+
120
+ #: views/widget-admin.php:49
121
+ msgid "Full Size"
122
+ msgstr ""
123
+
124
+ #: views/widget-admin.php:50
125
+ msgid "Thumbnail"
126
+ msgstr ""
127
+
128
+ #: views/widget-admin.php:51
129
+ msgid "Medium"
130
+ msgstr ""
131
+
132
+ #: views/widget-admin.php:52
133
+ msgid "Large"
134
+ msgstr ""
135
+
136
+ #: views/widget-admin.php:54
137
+ msgid "Custom"
138
+ msgstr ""
lang/image-widget-it_IT.mo ADDED
Binary file
lang/image-widget-it_IT.po ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Translation of the Image Widget 4.0 WordPress plugin.
2
+ # This file is distributed under the same license as the the Image Widget package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Image Widget\n"
6
+ "POT-Creation-Date: 2013-01-30 23:34-0800\n"
7
+ "PO-Revision-Date: 2013-02-02 14:12+0100\n"
8
+ "Last-Translator: \n"
9
+ "Language-Team: @ModernTribe <pro@tri.be>\n"
10
+ "Language: English\n"
11
+ "MIME-Version: 1.0\n"
12
+ "Content-Type: text/plain; charset=UTF-8\n"
13
+ "Content-Transfer-Encoding: 8bit\n"
14
+ "X-Generator: Poedit 1.5.4\n"
15
+ "X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e\n"
16
+ "X-Poedit-Basepath: .\n"
17
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
+ "X-Poedit-SourceCharset: UTF-8\n"
19
+
20
+ #: image-widget.php:40
21
+ msgid "Showcase a single image with a Title, URL, and a Description"
22
+ msgstr "Mostra una singola immagine con un Titolo, URL e una Descrizione"
23
+
24
+ #: image-widget.php:42
25
+ msgid "Image Widget"
26
+ msgstr "Widget Immagine"
27
+
28
+ #: image-widget.php:74
29
+ #: views/widget-admin.php:13
30
+ msgid "Select an Image"
31
+ msgstr "Seleziona un'immagine"
32
+
33
+ #: image-widget.php:75
34
+ #: lib/ImageWidgetDeprecated.php:66
35
+ msgid "Insert Into Widget"
36
+ msgstr "Inserisci nel Widget"
37
+
38
+ #: image-widget.php:390
39
+ #, php-format
40
+ msgid "Thanks for upgrading the Image Widget! If you like this plugin, please consider <a href=\"%s\" target=\"_blank\">rating it</a> and maybe even check out our premium plugins including our <a href=\"%s\" target=\"_blank\">Events Calendar Pro</a>!"
41
+ msgstr "Grazie per aver aggiornato il Widget Immagine! Se questo plugin ti piace, considera <a href=\"%s\" target=\"_blank\">un voto</a> e scopri i nostri premium plugins, incluso il nostro <a href=\"%s\" target=\"_blank\">Events Calendar Pro</a>!"
42
+
43
+ #: image-widget.php:405
44
+ #, php-format
45
+ msgid "Check out our other <a href=\"%s\" target=\"_blank\">plugins</a> including our <a href=\"%s\" target=\"_blank\">Events Calendar Pro</a>!"
46
+ msgstr "Scopri gli altri nostri <a href=\"%s\" target=\"_blank\">plugins</a>, incluso il nostro <a href=\"%s\" target=\"_blank\">Events Calendar Pro</a>!"
47
+
48
+ #: views/widget-admin.deprecated.php:10
49
+ #: views/widget-admin.php:23
50
+ msgid "Title"
51
+ msgstr "Titolo"
52
+
53
+ #: views/widget-admin.deprecated.php:13
54
+ msgid "Image"
55
+ msgstr "Immagine"
56
+
57
+ #: views/widget-admin.deprecated.php:17
58
+ msgid "Change Image"
59
+ msgstr "Cambia Immagine"
60
+
61
+ #: views/widget-admin.deprecated.php:17
62
+ msgid "Add Image"
63
+ msgstr "Aggiungi Immagine"
64
+
65
+ #: views/widget-admin.deprecated.php:25
66
+ #: views/widget-admin.php:29
67
+ msgid "Caption"
68
+ msgstr "Didascalia"
69
+
70
+ #: views/widget-admin.deprecated.php:28
71
+ #: views/widget-admin.php:32
72
+ msgid "Link"
73
+ msgstr "Link"
74
+
75
+ #: views/widget-admin.deprecated.php:31
76
+ #: views/widget-admin.php:35
77
+ msgid "Stay in Window"
78
+ msgstr "Apri nella stessa finestra"
79
+
80
+ #: views/widget-admin.deprecated.php:32
81
+ #: views/widget-admin.php:36
82
+ msgid "Open New Window"
83
+ msgstr "Apri in nuova finestra"
84
+
85
+ #: views/widget-admin.deprecated.php:35
86
+ #: views/widget-admin.php:66
87
+ msgid "Width"
88
+ msgstr "Larghezza"
89
+
90
+ #: views/widget-admin.deprecated.php:38
91
+ #: views/widget-admin.php:69
92
+ msgid "Height"
93
+ msgstr "Altezza"
94
+
95
+ #: views/widget-admin.deprecated.php:41
96
+ #: views/widget-admin.php:74
97
+ msgid "Align"
98
+ msgstr "Allineamento"
99
+
100
+ #: views/widget-admin.deprecated.php:43
101
+ #: views/widget-admin.php:76
102
+ msgid "none"
103
+ msgstr "nesssuno"
104
+
105
+ #: views/widget-admin.deprecated.php:44
106
+ #: views/widget-admin.php:77
107
+ msgid "left"
108
+ msgstr "sinistra"
109
+
110
+ #: views/widget-admin.deprecated.php:45
111
+ #: views/widget-admin.php:78
112
+ msgid "center"
113
+ msgstr "centro"
114
+
115
+ #: views/widget-admin.deprecated.php:46
116
+ #: views/widget-admin.php:79
117
+ msgid "right"
118
+ msgstr "destra"
119
+
120
+ #: views/widget-admin.deprecated.php:49
121
+ #: views/widget-admin.php:26
122
+ msgid "Alternate Text"
123
+ msgstr "Testo Alternativo"
124
+
125
+ #: views/widget-admin.php:44
126
+ msgid "Size"
127
+ msgstr "Dimensioni"
128
+
129
+ #: views/widget-admin.php:49
130
+ msgid "Full Size"
131
+ msgstr "Dimensioni Reali"
132
+
133
+ #: views/widget-admin.php:50
134
+ msgid "Thumbnail"
135
+ msgstr "Miniatura"
136
+
137
+ #: views/widget-admin.php:51
138
+ msgid "Medium"
139
+ msgstr "Media"
140
+
141
+ #: views/widget-admin.php:52
142
+ msgid "Large"
143
+ msgstr "Larga"
144
+
145
+ #: views/widget-admin.php:54
146
+ msgid "Custom"
147
+ msgstr "Personalizzata"
148
+
lang/image-widget-nl_NL.mo ADDED
Binary file
lang/image-widget-nl_NL.po ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Translation of the Image Widget 4.0 WordPress plugin.
2
+ # This file is distributed under the same license as the the Image Widget package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Image Widget\n"
6
+ "POT-Creation-Date: 2013-01-30 23:34-0800\n"
7
+ "PO-Revision-Date: 2013-02-01 06:14-0800\n"
8
+ "Last-Translator: Presis <contact@presis.nl>\n"
9
+ "Language-Team: @ModernTribe <pro@tri.be>\n"
10
+ "Language: English\n"
11
+ "MIME-Version: 1.0\n"
12
+ "Content-Type: text/plain; charset=UTF-8\n"
13
+ "Content-Transfer-Encoding: 8bit\n"
14
+ "X-Generator: Poedit 1.5.4\n"
15
+ "X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e\n"
16
+ "X-Poedit-Basepath: .\n"
17
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
+ "X-Poedit-SourceCharset: UTF-8\n"
19
+
20
+ #: image-widget.php:40
21
+ msgid "Showcase a single image with a Title, URL, and a Description"
22
+ msgstr "Toon een enkele afbeelding met een Titel, URL, en een Omschrijving"
23
+
24
+ #: image-widget.php:42
25
+ msgid "Image Widget"
26
+ msgstr "Afbeelding widget"
27
+
28
+ #: image-widget.php:74 views/widget-admin.php:13
29
+ msgid "Select an Image"
30
+ msgstr "Selecteer een afbeelding"
31
+
32
+ #: image-widget.php:75 lib/ImageWidgetDeprecated.php:66
33
+ msgid "Insert Into Widget"
34
+ msgstr "Invoegen in widget"
35
+
36
+ #: image-widget.php:390
37
+ #, php-format
38
+ msgid ""
39
+ "Thanks for upgrading the Image Widget! If you like this plugin, please "
40
+ "consider <a href=\"%s\" target=\"_blank\">rating it</a> and maybe even check "
41
+ "out our premium plugins including our <a href=\"%s\" target=\"_blank"
42
+ "\">Events Calendar Pro</a>!"
43
+ msgstr ""
44
+ "Bedankt voor het upgraden van Image Widget! Tevreden met deze plugin? Geef "
45
+ "een <a href=\"%s\" target=\"_blank\">waardering</a>. Of kijk eens naar onze "
46
+ "premium plugins, zoals <a href=\"%s\" target=\"_blank\">Events Calendar Pro</"
47
+ "a>!"
48
+
49
+ #: image-widget.php:405
50
+ #, php-format
51
+ msgid ""
52
+ "Check out our other <a href=\"%s\" target=\"_blank\">plugins</a> including "
53
+ "our <a href=\"%s\" target=\"_blank\">Events Calendar Pro</a>!"
54
+ msgstr ""
55
+ "Bekijk onze anders <a href=\"%s\" target=\"_blank\">plugins</a> zoals <a "
56
+ "href=\"%s\" target=\"_blank\">Events Calendar Pro</a>!"
57
+
58
+ #: views/widget-admin.deprecated.php:10 views/widget-admin.php:23
59
+ msgid "Title"
60
+ msgstr "Titel"
61
+
62
+ #: views/widget-admin.deprecated.php:13
63
+ msgid "Image"
64
+ msgstr "Afbeelding"
65
+
66
+ #: views/widget-admin.deprecated.php:17
67
+ msgid "Change Image"
68
+ msgstr "Wijzig afbeelding"
69
+
70
+ #: views/widget-admin.deprecated.php:17
71
+ msgid "Add Image"
72
+ msgstr "Afbeelding toevoegen"
73
+
74
+ #: views/widget-admin.deprecated.php:25 views/widget-admin.php:29
75
+ msgid "Caption"
76
+ msgstr "Onderschrift"
77
+
78
+ #: views/widget-admin.deprecated.php:28 views/widget-admin.php:32
79
+ msgid "Link"
80
+ msgstr "Link"
81
+
82
+ #: views/widget-admin.deprecated.php:31 views/widget-admin.php:35
83
+ msgid "Stay in Window"
84
+ msgstr "Blijf in zelfde venster"
85
+
86
+ #: views/widget-admin.deprecated.php:32 views/widget-admin.php:36
87
+ msgid "Open New Window"
88
+ msgstr "Open in nieuw venster"
89
+
90
+ #: views/widget-admin.deprecated.php:35 views/widget-admin.php:66
91
+ msgid "Width"
92
+ msgstr "Breedte"
93
+
94
+ #: views/widget-admin.deprecated.php:38 views/widget-admin.php:69
95
+ msgid "Height"
96
+ msgstr "Hoogte"
97
+
98
+ #: views/widget-admin.deprecated.php:41 views/widget-admin.php:74
99
+ msgid "Align"
100
+ msgstr "Uitlijning"
101
+
102
+ #: views/widget-admin.deprecated.php:43 views/widget-admin.php:76
103
+ msgid "none"
104
+ msgstr "geen"
105
+
106
+ #: views/widget-admin.deprecated.php:44 views/widget-admin.php:77
107
+ msgid "left"
108
+ msgstr "links"
109
+
110
+ #: views/widget-admin.deprecated.php:45 views/widget-admin.php:78
111
+ msgid "center"
112
+ msgstr "midden"
113
+
114
+ #: views/widget-admin.deprecated.php:46 views/widget-admin.php:79
115
+ msgid "right"
116
+ msgstr "rechts"
117
+
118
+ #: views/widget-admin.deprecated.php:49 views/widget-admin.php:26
119
+ msgid "Alternate Text"
120
+ msgstr "Alternatieve tekst"
121
+
122
+ #: views/widget-admin.php:44
123
+ msgid "Size"
124
+ msgstr "Formaat"
125
+
126
+ #: views/widget-admin.php:49
127
+ msgid "Full Size"
128
+ msgstr "Volledige groote"
129
+
130
+ #: views/widget-admin.php:50
131
+ msgid "Thumbnail"
132
+ msgstr "Thumbnail"
133
+
134
+ #: views/widget-admin.php:51
135
+ msgid "Medium"
136
+ msgstr "Gemiddeld"
137
+
138
+ #: views/widget-admin.php:52
139
+ msgid "Large"
140
+ msgstr "Groot"
141
+
142
+ #: views/widget-admin.php:54
143
+ msgid "Custom"
144
+ msgstr "Eigen"
lang/image-widget-sv_SE.mo ADDED
Binary file
lang/image-widget-sv_SE.po ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Translation of the Image Widget 4.0 WordPress plugin.
2
+ # This file is distributed under the same license as the the Image Widget package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Image Widget\n"
6
+ "POT-Creation-Date: 2013-01-30 23:34-0800\n"
7
+ "PO-Revision-Date: 2013-01-31 22:56+0100\n"
8
+ "Last-Translator: Tomas Lindhoff <tomas@xhost.se>\n"
9
+ "Language-Team: @ModernTribe <pro@tri.be>\n"
10
+ "Language: English\n"
11
+ "MIME-Version: 1.0\n"
12
+ "Content-Type: text/plain; charset=UTF-8\n"
13
+ "Content-Transfer-Encoding: 8bit\n"
14
+ "X-Generator: Poedit 1.5.4\n"
15
+ "X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e\n"
16
+ "X-Poedit-Basepath: .\n"
17
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
+ "X-Poedit-SourceCharset: UTF-8\n"
19
+
20
+ #: image-widget.php:40
21
+ msgid "Showcase a single image with a Title, URL, and a Description"
22
+ msgstr "Visa upp en bild med titel, url och en beskrivning"
23
+
24
+ #: image-widget.php:42
25
+ msgid "Image Widget"
26
+ msgstr "Bild Widget"
27
+
28
+ #: image-widget.php:74 views/widget-admin.php:13
29
+ msgid "Select an Image"
30
+ msgstr "Välj en bild"
31
+
32
+ #: image-widget.php:75 lib/ImageWidgetDeprecated.php:66
33
+ msgid "Insert Into Widget"
34
+ msgstr "Infoga i Widget"
35
+
36
+ #: image-widget.php:390
37
+ #, php-format
38
+ msgid ""
39
+ "Thanks for upgrading the Image Widget! If you like this plugin, please "
40
+ "consider <a href=\"%s\" target=\"_blank\">rating it</a> and maybe even check "
41
+ "out our premium plugins including our <a href=\"%s\" target=\"_blank"
42
+ "\">Events Calendar Pro</a>!"
43
+ msgstr ""
44
+ "Tack för att du uppgraderade Bild Widget! Om du gillar detta tillägg skulle "
45
+ "vi uppskatta om du <a href=\"%s\" target=\"_blank\">betygsätter den</a> och "
46
+ "eventuellt titter på våra premium tillägg som t ex <a href=\"%s\" target="
47
+ "\"_blank\">Events Calendar Pro</a>!"
48
+
49
+ #: image-widget.php:405
50
+ #, php-format
51
+ msgid ""
52
+ "Check out our other <a href=\"%s\" target=\"_blank\">plugins</a> including "
53
+ "our <a href=\"%s\" target=\"_blank\">Events Calendar Pro</a>!"
54
+ msgstr ""
55
+ "Se våra andra <a href=\"%s\" target=\"_blank\">tillägg</a> som bland annat "
56
+ "inkluderar <a href=\"%s\" target=\"_blank\">Events Calendar Pro</a>!"
57
+
58
+ #: views/widget-admin.deprecated.php:10 views/widget-admin.php:23
59
+ msgid "Title"
60
+ msgstr "Titel"
61
+
62
+ #: views/widget-admin.deprecated.php:13
63
+ msgid "Image"
64
+ msgstr "Bild"
65
+
66
+ #: views/widget-admin.deprecated.php:17
67
+ msgid "Change Image"
68
+ msgstr "Byt bild"
69
+
70
+ #: views/widget-admin.deprecated.php:17
71
+ msgid "Add Image"
72
+ msgstr "Lägg till bild"
73
+
74
+ #: views/widget-admin.deprecated.php:25 views/widget-admin.php:29
75
+ msgid "Caption"
76
+ msgstr "Bildtext"
77
+
78
+ #: views/widget-admin.deprecated.php:28 views/widget-admin.php:32
79
+ msgid "Link"
80
+ msgstr "Länk"
81
+
82
+ #: views/widget-admin.deprecated.php:31 views/widget-admin.php:35
83
+ msgid "Stay in Window"
84
+ msgstr "Stanna i samma fönster"
85
+
86
+ #: views/widget-admin.deprecated.php:32 views/widget-admin.php:36
87
+ msgid "Open New Window"
88
+ msgstr "Öppna i ett nytt fönster"
89
+
90
+ #: views/widget-admin.deprecated.php:35 views/widget-admin.php:66
91
+ msgid "Width"
92
+ msgstr "Bredd"
93
+
94
+ #: views/widget-admin.deprecated.php:38 views/widget-admin.php:69
95
+ msgid "Height"
96
+ msgstr "Höjd"
97
+
98
+ #: views/widget-admin.deprecated.php:41 views/widget-admin.php:74
99
+ msgid "Align"
100
+ msgstr "Justering"
101
+
102
+ #: views/widget-admin.deprecated.php:43 views/widget-admin.php:76
103
+ msgid "none"
104
+ msgstr "Ingen"
105
+
106
+ #: views/widget-admin.deprecated.php:44 views/widget-admin.php:77
107
+ msgid "left"
108
+ msgstr "Vänster"
109
+
110
+ #: views/widget-admin.deprecated.php:45 views/widget-admin.php:78
111
+ msgid "center"
112
+ msgstr "Centrerad"
113
+
114
+ #: views/widget-admin.deprecated.php:46 views/widget-admin.php:79
115
+ msgid "right"
116
+ msgstr "Höger"
117
+
118
+ #: views/widget-admin.deprecated.php:49 views/widget-admin.php:26
119
+ msgid "Alternate Text"
120
+ msgstr "Alternativ text"
121
+
122
+ #: views/widget-admin.php:44
123
+ msgid "Size"
124
+ msgstr "Storlek"
125
+
126
+ #: views/widget-admin.php:49
127
+ msgid "Full Size"
128
+ msgstr "Full storlek"
129
+
130
+ #: views/widget-admin.php:50
131
+ msgid "Thumbnail"
132
+ msgstr "Miniatyr"
133
+
134
+ #: views/widget-admin.php:51
135
+ msgid "Medium"
136
+ msgstr "Medium"
137
+
138
+ #: views/widget-admin.php:52
139
+ msgid "Large"
140
+ msgstr "Stor"
141
+
142
+ #: views/widget-admin.php:54
143
+ msgid "Custom"
144
+ msgstr "Anpassad"
lang/{image_widget-cs_CZ.mo → old/image_widget-cs_CZ.mo} RENAMED
File without changes
lang/{image_widget-cs_CZ.po → old/image_widget-cs_CZ.po} RENAMED
File without changes
lang/{image_widget-de_DE.mo → old/image_widget-de_DE.mo} RENAMED
File without changes
lang/{image_widget-de_DE.po → old/image_widget-de_DE.po} RENAMED
File without changes
lang/{image_widget-fr_FR.mo → old/image_widget-fr_FR.mo} RENAMED
File without changes
lang/{image_widget-fr_FR.po → old/image_widget-fr_FR.po} RENAMED
File without changes
lang/old/image_widget-it_IT.mo ADDED
Binary file
lang/old/image_widget-it_IT.po ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Translation of the Image Widget 3.1.4 WordPress plugin.
2
+ # This file is distributed under the same license as the the Image Widget package.
3
+ # Rüdiger Weiß <ruediger@mac.com>, 2010.
4
+ #
5
+ msgid ""
6
+ msgstr ""
7
+ "Project-Id-Version: Image Widget 3.1.4\n"
8
+ "Report-Msgid-Bugs-To: \n"
9
+ "POT-Creation-Date: 2010-01-30 14:15+0100\n"
10
+ "PO-Revision-Date: 2012-11-14 16:44+0100\n"
11
+ "Last-Translator: \n"
12
+ "Language-Team: Rüdiger Weiß <ruediger@mac.com>\n"
13
+ "MIME-Version: 1.0\n"
14
+ "Content-Type: text/plain; charset=UTF-8\n"
15
+ "Content-Transfer-Encoding: 8bit\n"
16
+ "X-Poedit-Language: Czech\n"
17
+ "X-Poedit-Country: CZECH REPUBLIC\n"
18
+ "X-Poedit-SourceCharset: iso-8859-1\n"
19
+ "X-Poedit-KeywordsList: __;_e\n"
20
+ "X-Poedit-Basepath: .\n"
21
+
22
+ #: image-widget.php:33
23
+ msgid "Showcase a single image with a Title, URL, and a Description"
24
+ msgstr "Mostra una singola immagine con un Titolo, URL e una Descrizione"
25
+
26
+ #: image-widget.php:35
27
+ msgid "Image Widget"
28
+ msgstr "Widget Immagine"
29
+
30
+ #: image-widget.php:114
31
+ msgid "Insert Into Widget"
32
+ msgstr "Inserisci in Widget"
33
+
34
+ #: image-widget.php:265
35
+ msgid "Title:"
36
+ msgstr "Titolo:"
37
+
38
+ #: image-widget.php:268
39
+ msgid "Image:"
40
+ msgstr "Immagine:"
41
+
42
+ #: image-widget.php:272
43
+ msgid "Change Image"
44
+ msgstr "Cambia Immagine"
45
+
46
+ #: image-widget.php:272
47
+ msgid "Add Image"
48
+ msgstr "Aggiungi Immagine"
49
+
50
+ #: image-widget.php:295
51
+ msgid "Caption:"
52
+ msgstr "Didascalia:"
53
+
54
+ #: image-widget.php:298
55
+ msgid "Link:"
56
+ msgstr "Link:"
57
+
58
+ #: image-widget.php:301
59
+ msgid "Stay in Window"
60
+ msgstr "Rimani nella Finestra"
61
+
62
+ #: image-widget.php:302
63
+ msgid "Open New Window"
64
+ msgstr "Apri Nuova Finestra"
65
+
66
+ #: image-widget.php:305
67
+ msgid "Width:"
68
+ msgstr "Larghezza:"
69
+
70
+ #: image-widget.php:308
71
+ msgid "Height:"
72
+ msgstr "Altezza:"
73
+
74
+ #: image-widget.php:311
75
+ msgid "Align:"
76
+ msgstr "Allineamento:"
77
+
78
+ #: image-widget.php:313
79
+ msgid "none"
80
+ msgstr "nessuno"
81
+
82
+ #: image-widget.php:314
83
+ msgid "left"
84
+ msgstr "sinistra"
85
+
86
+ #: image-widget.php:315
87
+ msgid "center"
88
+ msgstr "centro"
89
+
90
+ #: image-widget.php:316
91
+ msgid "right"
92
+ msgstr "destra"
93
+
94
+ #: image-widget.php:331
95
+ msgid "Alternate Text:"
96
+ msgstr "Testo Alternativo:"
97
+
lang/{image_widget-ja.mo → old/image_widget-ja.mo} RENAMED
File without changes
lang/{image_widget-ja.po → old/image_widget-ja.po} RENAMED
File without changes
lang/{image_widget-nl_NL.mo → old/image_widget-nl_NL.mo} RENAMED
File without changes
lang/{image_widget-nl_NL.po → old/image_widget-nl_NL.po} RENAMED
File without changes
lang/{image_widget-pl_PL.mo → old/image_widget-pl_PL.mo} RENAMED
File without changes
lang/{image_widget-pl_PL.po → old/image_widget-pl_PL.po} RENAMED
File without changes
lang/{image_widget-pt_BR.mo → old/image_widget-pt_BR.mo} RENAMED
File without changes
lang/{image_widget-pt_BR.po → old/image_widget-pt_BR.po} RENAMED
File without changes
lang/{image_widget-ro_RO.mo → old/image_widget-ro_RO.mo} RENAMED
File without changes
lang/{image_widget-ro_RO.po → old/image_widget-ro_RO.po} RENAMED
File without changes
lang/{image_widget-sv_SE.mo → old/image_widget-sv_SE.mo} RENAMED
File without changes
lang/{image_widget-sv_SE.po → old/image_widget-sv_SE.po} RENAMED
File without changes
lib/ImageWidgetDeprecated.php ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Deprecated image upload integration code to support legacy versions of WordPress
4
+ * @author Modern Tribe, Inc.
5
+ */
6
+
7
+ class ImageWidgetDeprecated {
8
+
9
+ private $id_base;
10
+
11
+ function __construct( $widget ) {
12
+ add_action( 'admin_init', array( $this, 'admin_setup' ) );
13
+ $this->id_base = $widget->id_base;
14
+ }
15
+
16
+ function admin_setup() {
17
+ global $pagenow;
18
+ if ( 'widgets.php' == $pagenow ) {
19
+ wp_enqueue_style( 'thickbox' );
20
+ wp_enqueue_script( 'tribe-image-widget', plugins_url('resources/js/image-widget.deprecated.js', dirname(__FILE__)), array('thickbox'), FALSE, TRUE );
21
+ }
22
+ elseif ( 'media-upload.php' == $pagenow || 'async-upload.php' == $pagenow ) {
23
+ wp_enqueue_script( 'tribe-image-widget-fix-uploader', plugins_url('resources/js/image-widget.deprecated.upload-fixer.js', dirname(__FILE__)), array('jquery'), FALSE, TRUE );
24
+ add_filter( 'image_send_to_editor', array( $this,'image_send_to_editor'), 1, 8 );
25
+ add_filter( 'gettext', array( $this, 'replace_text_in_thickbox' ), 1, 3 );
26
+ add_filter( 'media_upload_tabs', array( $this, 'media_upload_tabs' ) );
27
+ add_filter( 'image_widget_image_url', array( $this, 'https_cleanup' ) );
28
+ }
29
+ $this->fix_async_upload_image();
30
+ }
31
+
32
+ function fix_async_upload_image() {
33
+ if(isset($_REQUEST['attachment_id'])) {
34
+ $id = (int) $_REQUEST['attachment_id'];
35
+ $GLOBALS['post'] = get_post( $id );
36
+ }
37
+ }
38
+
39
+ /**
40
+ * Test context to see if the uploader is being used for the image widget or for other regular uploads
41
+ *
42
+ * @author Modern Tribe, Inc. (Peter Chester)
43
+ */
44
+ function is_sp_widget_context() {
45
+ if ( isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'],$this->id_base) !== false ) {
46
+ return true;
47
+ } elseif ( isset($_REQUEST['_wp_http_referer']) && strpos($_REQUEST['_wp_http_referer'],$this->id_base) !== false ) {
48
+ return true;
49
+ } elseif ( isset($_REQUEST['widget_id']) && strpos($_REQUEST['widget_id'],$this->id_base) !== false ) {
50
+ return true;
51
+ }
52
+ return false;
53
+ }
54
+
55
+ /**
56
+ * Somewhat hacky way of replacing "Insert into Post" with "Insert into Widget"
57
+ *
58
+ * @param string $translated_text text that has already been translated (normally passed straight through)
59
+ * @param string $source_text text as it is in the code
60
+ * @param string $domain domain of the text
61
+ * @author Modern Tribe, Inc. (Peter Chester)
62
+ */
63
+ function replace_text_in_thickbox($translated_text, $source_text, $domain) {
64
+ if ( $this->is_sp_widget_context() ) {
65
+ if ('Insert into Post' == $source_text) {
66
+ return __('Insert Into Widget', 'image_widget' );
67
+ }
68
+ }
69
+ return $translated_text;
70
+ }
71
+
72
+ /**
73
+ * Filter image_end_to_editor results
74
+ *
75
+ * @param string $html
76
+ * @param int $id
77
+ * @param string $alt
78
+ * @param string $title
79
+ * @param string $align
80
+ * @param string $url
81
+ * @param array $size
82
+ * @return string javascript array of attachment url and id or just the url
83
+ * @author Modern Tribe, Inc. (Peter Chester)
84
+ */
85
+ function image_send_to_editor( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ) {
86
+ // Normally, media uploader return an HTML string (in this case, typically a complete image tag surrounded by a caption).
87
+ // Don't change that; instead, send custom javascript variables back to opener.
88
+ // Check that this is for the widget. Shouldn't hurt anything if it runs, but let's do it needlessly.
89
+ if ( $this->is_sp_widget_context() ) {
90
+ if ($alt=='') $alt = $title;
91
+ ?>
92
+ <script type="text/javascript">
93
+ // send image variables back to opener
94
+ var win = window.dialogArguments || opener || parent || top;
95
+ win.IW_html = '<?php echo addslashes($html); ?>';
96
+ win.IW_img_id = '<?php echo $id; ?>';
97
+ win.IW_alt = '<?php echo addslashes($alt); ?>';
98
+ win.IW_caption = '<?php echo addslashes($caption); ?>';
99
+ win.IW_title = '<?php echo addslashes($title); ?>';
100
+ win.IW_align = '<?php echo esc_attr($align); ?>';
101
+ win.IW_url = '<?php echo esc_url($url); ?>';
102
+ win.IW_size = '<?php echo esc_attr($size); ?>';
103
+ </script>
104
+ <?php
105
+ }
106
+ return $html;
107
+ }
108
+
109
+ /**
110
+ * Remove from url tab until that functionality is added to widgets.
111
+ *
112
+ * @param array $tabs
113
+ * @author Modern Tribe, Inc. (Peter Chester)
114
+ */
115
+ function media_upload_tabs($tabs) {
116
+ if ( $this->is_sp_widget_context() ) {
117
+ unset($tabs['type_url']);
118
+ }
119
+ return $tabs;
120
+ }
121
+
122
+ /**
123
+ * Adjust the image url on output to account for SSL.
124
+ *
125
+ * @param string $imageurl
126
+ * @return string $imageurl
127
+ * @author Modern Tribe, Inc. (Peter Chester)
128
+ */
129
+ function https_cleanup( $imageurl = '' ) {
130
+ // TODO: 3.5: Document that this is deprecated???
131
+ if( isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on" ) {
132
+ $imageurl = str_replace('http://', 'https://', $imageurl);
133
+ } else {
134
+ $imageurl = str_replace('https://', 'http://', $imageurl);
135
+ }
136
+ return $imageurl;
137
+ }
138
+
139
+
140
+
141
+ /**
142
+ * Retrieve resized image URL
143
+ *
144
+ * @param int $id Post ID or Attachment ID
145
+ * @param int $width desired width of image (optional)
146
+ * @param int $height desired height of image (optional)
147
+ * @return string URL
148
+ * @author Modern Tribe, Inc. (Peter Chester)
149
+ */
150
+ public static function get_image_url( $id, $width=false, $height=false ) {
151
+ /**/
152
+ // Get attachment and resize but return attachment path (needs to return url)
153
+ $attachment = wp_get_attachment_metadata( $id );
154
+ $attachment_url = wp_get_attachment_url( $id );
155
+ if (isset($attachment_url)) {
156
+ if ($width && $height) {
157
+ $uploads = wp_upload_dir();
158
+ $imgpath = $uploads['basedir'].'/'.$attachment['file'];
159
+ if (WP_DEBUG) {
160
+ error_log(__CLASS__.'->'.__FUNCTION__.'() $imgpath = '.$imgpath);
161
+ }
162
+ $image = self::resize_image( $imgpath, $width, $height );
163
+ if ( $image && !is_wp_error( $image ) ) {
164
+ $image = path_join( dirname($attachment_url), basename($image) );
165
+ } else {
166
+ $image = $attachment_url;
167
+ }
168
+ } else {
169
+ $image = $attachment_url;
170
+ }
171
+ if (isset($image)) {
172
+ return $image;
173
+ }
174
+ }
175
+ }
176
+
177
+ public static function resize_image( $file, $max_w, $max_h ) {
178
+ if ( function_exists('wp_get_image_editor') ) {
179
+ $dest_file = $file;
180
+ if ( function_exists('wp_get_image_editor') ) {
181
+ $editor = wp_get_image_editor( $file );
182
+ if ( is_wp_error( $editor ) )
183
+ return $editor;
184
+
185
+ $resized = $editor->resize( $max_w, $max_h );
186
+ if ( is_wp_error( $resized ) )
187
+ return $resized;
188
+
189
+ $dest_file = $editor->generate_filename();
190
+ $saved = $editor->save( $dest_file );
191
+
192
+ if ( is_wp_error( $saved ) )
193
+ return $saved;
194
+
195
+ }
196
+ return $dest_file;
197
+ } else {
198
+ return image_resize( $file, $max_w, $max_h );
199
+ }
200
+ }
201
+
202
+ }
readme.txt CHANGED
@@ -1,13 +1,15 @@
1
  === Image Widget ===
2
  Contributors: ModernTribe, peterchester, mattwiebe
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4BSPTNFFY6AL6
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
 
 
 
11
  Simple image widget that uses native Wordpress upload thickbox to add image widgets to your site.
12
 
13
  * MU Compatible
@@ -17,25 +19,23 @@ Simple image widget that uses native Wordpress upload thickbox to add image widg
17
  * Very versatile. All fields are optional.
18
  * Upload, link to external image, or select an image from your media collection using the built in thickbox browser.
19
  * Supports override of template so that you can override the template for your theme!
20
- * Supports HTTPS/SSL image urls
21
 
22
- Supported Languages (feel free to contribute other languages):
23
 
24
  * Dutch
25
- * French
26
- * German
27
- * Japanese
28
- * Portuguese
29
- * Romanian
30
  * Swedish
31
- * Czech
 
 
 
32
 
33
  This plugin is actively supported and we will do our best to help you. In return we simply as 3 things:
34
 
35
  1. Help Out. If you see a question on the forum you can help with or have a great idea and want to code it up and submit a patch, that would be just plain awesome and we will shower your with praise. Might even be a good way to get to know us and lead to some paid work if you freelance. Also, we are happy to post translations if you provide them.
36
  1. Donate - if this is generating enough revenue to support our time it makes all the difference in the world
37
  https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4BSPTNFFY6AL6
38
- 1. Support us by buying our Premium plugins. In particular, check out our Events Calendar Pro http://tri.be/wordpress-events-calendar-pro/
39
 
40
  == Installation ==
41
 
@@ -53,7 +53,7 @@ Please visit the forum for questions or comments: http://wordpress.org/tags/imag
53
  = Requirements =
54
 
55
  * PHP 5.1 or above
56
- * WordPress 3.0 or above
57
 
58
  == Documentation ==
59
 
@@ -84,20 +84,16 @@ This is actually a pretty typical filter in widgets and is applied to the widget
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
 
@@ -109,6 +105,12 @@ Accepts additional $args and $instance arguments.
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.
@@ -119,8 +121,43 @@ Accepts additional $args and $instance arguments.
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.
@@ -316,10 +353,20 @@ Thank you @smurkas, @squigie and @laurie!!! Special thanks to Cameron Clark fro
316
  * WP 2.7.1 Compatibility
317
  * Class encapsulation
318
 
 
 
 
 
 
 
 
 
 
 
319
  == Screenshots ==
320
 
321
  1. Image Widget admin screen.
322
- 1. Thickbox uploader for the Image Widget
323
  1. Image Widget on the front of a plain Wordpress install.
324
 
325
  == Frequently Asked Questions ==
1
  === Image Widget ===
2
  Contributors: ModernTribe, peterchester, mattwiebe
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4BSPTNFFY6AL6
4
+ Tags: widget, image, ad, banner, simple, upload, sidebar, admin, thickbox, resize, italian, swedish, dutch, ssl, https, widget-only
5
+ Requires at least: 3.5
6
+ Tested up to: 3.6
7
+ Stable tag: 4.0
8
 
9
  == Description ==
10
 
11
+ *NEW: The Image Widget has been UPGRADED to work with WordPress 3.5+!!!*
12
+
13
  Simple image widget that uses native Wordpress upload thickbox to add image widgets to your site.
14
 
15
  * MU Compatible
19
  * Very versatile. All fields are optional.
20
  * Upload, link to external image, or select an image from your media collection using the built in thickbox browser.
21
  * Supports override of template so that you can override the template for your theme!
 
22
 
23
+ Supported Languages:
24
 
25
  * Dutch
26
+ * Italian
 
 
 
 
27
  * Swedish
28
+
29
+ If you would like your own language to be supported, please contribute translations here:
30
+
31
+ http://wordpress.org/support/topic/image-widget-40-translations-needed-2
32
 
33
  This plugin is actively supported and we will do our best to help you. In return we simply as 3 things:
34
 
35
  1. Help Out. If you see a question on the forum you can help with or have a great idea and want to code it up and submit a patch, that would be just plain awesome and we will shower your with praise. Might even be a good way to get to know us and lead to some paid work if you freelance. Also, we are happy to post translations if you provide them.
36
  1. Donate - if this is generating enough revenue to support our time it makes all the difference in the world
37
  https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4BSPTNFFY6AL6
38
+ 1. Support us by buying our Premium plugins. In particular, check out our Events Calendar Pro http://tri.be/wordpress-events-calendar-pro/?src=imagewidget
39
 
40
  == Installation ==
41
 
53
  = Requirements =
54
 
55
  * PHP 5.1 or above
56
+ * WordPress 3.5 or above
57
 
58
  == Documentation ==
59
 
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_attachment_id*
 
 
 
88
 
89
+ Filters the attachment id of the image.
 
 
90
  Accepts additional $args and $instance arguments.
91
 
92
+ *image_widget_image_url*
93
 
94
+ Filters the url of the image displayed in the widget.
95
  Accepts additional $args and $instance arguments.
96
+ THIS IS DEPRECATED AND WILL EVENTUALLY BE DELETED
97
 
98
  *image_widget_image_width*
99
 
105
  Filters the display height of the image.
106
  Accepts additional $args and $instance arguments.
107
 
108
+ *image_widget_image_size*
109
+
110
+ Filters the selected image 'size' corresponding to WordPress registered sizes.
111
+ If this is set to 'tribe_image_widget_custom' then the width and height are used instead.
112
+ Accepts additional $args and $instance arguments.
113
+
114
  *image_widget_image_align*
115
 
116
  Filters the display alignment of the image.
121
  Filters the alt text of the image.
122
  Accepts additional $args and $instance arguments.
123
 
124
+ *image_widget_image_link*
125
+
126
+ Filters the url that the image links to.
127
+ Accepts additional $args and $instance arguments.
128
+
129
+ *image_widget_image_link_target*
130
+
131
+ Filters the link target of the image link.
132
+ Accepts additional $args and $instance arguments.
133
+
134
+ *image_widget_image_attributes*
135
+
136
+ Filters a list of image attributes used in the image output. Similar to 'wp_get_attachment_image_attributes'
137
+ Accepts $instance arguments
138
+
139
+ *image_widget_link_attributes*
140
+
141
+ Filters a list of attributes used in the image link. Similar to 'wp_get_attachment_image_attributes'
142
+ Accepts $instance arguments
143
+
144
  == Changelog ==
145
 
146
+ = 4.0 =
147
+
148
+ * Significant upgrades to support the new WordPress media manager (Thank you @kyleunzicker, @dancameron, @dudekpj, @JakePT)
149
+ * Significant improvements the administrative user interface.
150
+ * Abstracted support for older versions of WordPress so that that we don't break old versions with this upgrade (Though there's no reason you should up grade this widget and NOT your WP install! You should always keep WordPress core up to date!)
151
+ * Added 'image_widget_link_attributes' filter to easily process link attributes and to default to having the link 'title' be the 'alt' or 'title' content. (Thank you @ZeroGravity, @pixelyzed, and @javiandgo)
152
+ * Updated Translations
153
+ ** Swedish (Tomas Lindhoff <tomas@xhost.se>)
154
+ ** Dutch (Presis <contact@presis.nl>)
155
+ ** Italian (@maxgx)
156
+
157
+ = 3.3.8 =
158
+
159
+ * Added italian translations courtesy of @maxgx
160
+
161
  = 3.3.7 =
162
 
163
  * Add filters so that people can more easily adjust the output of the widget as per @TCBarrett's request.
353
  * WP 2.7.1 Compatibility
354
  * Class encapsulation
355
 
356
+ == Upgrade Notice ==
357
+
358
+ = 4.0 =
359
+
360
+ Please be advised that this is a significant upgrade. You should definitely back up your database before updating in case your existing image widgets have any problems.
361
+
362
+ Also, several languages will no longer be supported until new translations are submitted. Currently, we have support for Italian, Dutch, and Swedish. If you would like to contribute your own language files, please post links here:
363
+
364
+ http://wordpress.org/support/topic/image-widget-40-translations-needed-2
365
+
366
  == Screenshots ==
367
 
368
  1. Image Widget admin screen.
369
+ 1. Media manager integration.
370
  1. Image Widget on the front of a plain Wordpress install.
371
 
372
  == Frequently Asked Questions ==
resources/js/image-widget.deprecated.js ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var imageWidget;
2
+
3
+ (function($){
4
+
5
+ imageWidget = {
6
+
7
+ sendToEditor : function(h) {
8
+ // ignore content returned from media uploader and use variables passed to window instead
9
+
10
+ // store attachment id in hidden field
11
+ $( '#widget-'+self.IW_instance+'-image' ).val( self.IW_img_id );
12
+
13
+ // display attachment preview
14
+ $( '#display-widget-'+self.IW_instance+'-image' ).html( self.IW_html );
15
+
16
+ // change width & height fields in widget to match image
17
+ $( '#widget-'+self.IW_instance+'-width' ).val($( '#display-widget-'+self.IW_instance+'-image img').attr('width'));
18
+ $( '#widget-'+self.IW_instance+'-height' ).val($( '#display-widget-'+self.IW_instance+'-image img').attr('height'));
19
+
20
+ // set alignment in widget
21
+ $( '#widget-'+self.IW_instance+'-align' ).val(self.IW_align);
22
+
23
+ // set title in widget
24
+ $( '#widget-'+self.IW_instance+'-title' ).val(self.IW_title);
25
+
26
+ // set caption in widget
27
+ $( '#widget-'+self.IW_instance+'-description' ).val(self.IW_caption);
28
+
29
+ // set alt text in widget
30
+ $( '#widget-'+self.IW_instance+'-alt' ).val(self.IW_alt);
31
+
32
+ // set link in widget
33
+ $( '#widget-'+self.IW_instance+'-link' ).val(self.IW_url);
34
+
35
+ // close thickbox
36
+ tb_remove();
37
+
38
+ // change button text
39
+ $('#add_image-widget-'+self.IW_instance+'-image').html($('#add_image-widget-'+self.IW_instance+'-image').html().replace(/Add Image/g, 'Change Image'));
40
+ },
41
+
42
+ changeImgWidth : function(instance) {
43
+ var width = $( '#widget-'+instance+'-width' ).val();
44
+ var height = Math.round(width / imageWidget.imgRatio(instance));
45
+ imageWidget.changeImgSize(instance,width,height);
46
+ },
47
+
48
+ changeImgHeight : function(instance) {
49
+ var height = $( '#widget-'+instance+'-height' ).val();
50
+ var width = Math.round(height * imageWidget.imgRatio(instance));
51
+ imageWidget.changeImgSize(instance,width,height);
52
+ },
53
+
54
+ imgRatio : function(instance) {
55
+ var width_old = $( '#display-widget-'+instance+'-image img').attr('width');
56
+ var height_old = $( '#display-widget-'+instance+'-image img').attr('height');
57
+ var ratio = width_old / height_old;
58
+ return ratio;
59
+ },
60
+
61
+ changeImgSize : function(instance,width,height) {
62
+ if (isNaN(width) || width < 1) {
63
+ $( '#widget-'+instance+'-width' ).val('');
64
+ width = 'none';
65
+ } else {
66
+ $( '#widget-'+instance+'-width' ).val(width);
67
+ width = width + 'px';
68
+ }
69
+ $( '#display-widget-'+instance+'-image img' ).css({
70
+ 'width':width
71
+ });
72
+
73
+ if (isNaN(height) || height < 1) {
74
+ $( '#widget-'+instance+'-height' ).val('');
75
+ height = 'none';
76
+ } else {
77
+ $( '#widget-'+instance+'-height' ).val(height);
78
+ height = height + 'px';
79
+ }
80
+ $( '#display-widget-'+instance+'-image img' ).css({
81
+ 'height':height
82
+ });
83
+ },
84
+
85
+ changeImgAlign : function(instance) {
86
+ var align = $( '#widget-'+instance+'-align' ).val();
87
+ $( '#display-widget-'+instance+'-image img' ).attr(
88
+ 'class', (align == 'none' ? '' : 'align'+align)
89
+ );
90
+ },
91
+
92
+ imgHandler : function(event) {
93
+ event.preventDefault();
94
+ window.send_to_editor = imageWidget.sendToEditor;
95
+ tb_show("Add an Image", event.target.href, false);
96
+ },
97
+
98
+ setActiveWidget : function(instance_id) {
99
+ self.IW_instance = instance_id;
100
+ }
101
+
102
+ };
103
+
104
+ $(document).ready(function() {
105
+ // Use new style event handling since $.fn.live() will be deprecated
106
+ if ( typeof $.fn.on !== 'undefined' ) {
107
+ $("#wpbody").on("click", ".thickbox-image-widget", imageWidget.imgHandler);
108
+ }
109
+ else {
110
+ $("a.thickbox-image-widget").live('click', imageWidget.imgHandler);
111
+ }
112
+
113
+ // Modify thickbox link to fit window. Adapted from wp-admin\js\media-upload.dev.js.
114
+ $('a.thickbox-image-widget').each( function() {
115
+ var href = $(this).attr('href'), width = $(window).width(), H = $(window).height(), W = ( 720 < width ) ? 720 : width;
116
+ if ( ! href ) return;
117
+ href = href.replace(/&width=[0-9]+/g, '');
118
+ href = href.replace(/&height=[0-9]+/g, '');
119
+ $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) );
120
+ });
121
+ });
122
+
123
+ })(jQuery);
resources/js/{image-widget-upload-fixer.js → image-widget.deprecated.upload-fixer.js} RENAMED
File without changes
resources/js/image-widget.js CHANGED
@@ -1,123 +1,108 @@
1
- var imageWidget;
2
-
3
- (function($){
4
-
5
- imageWidget = {
6
-
7
- sendToEditor : function(h) {
8
- // ignore content returned from media uploader and use variables passed to window instead
9
-
10
- // store attachment id in hidden field
11
- $( '#widget-'+self.IW_instance+'-image' ).val( self.IW_img_id );
12
-
13
- // display attachment preview
14
- $( '#display-widget-'+self.IW_instance+'-image' ).html( self.IW_html );
15
-
16
- // change width & height fields in widget to match image
17
- $( '#widget-'+self.IW_instance+'-width' ).val($( '#display-widget-'+self.IW_instance+'-image img').attr('width'));
18
- $( '#widget-'+self.IW_instance+'-height' ).val($( '#display-widget-'+self.IW_instance+'-image img').attr('height'));
19
-
20
- // set alignment in widget
21
- $( '#widget-'+self.IW_instance+'-align' ).val(self.IW_align);
22
-
23
- // set title in widget
24
- $( '#widget-'+self.IW_instance+'-title' ).val(self.IW_title);
25
-
26
- // set caption in widget
27
- $( '#widget-'+self.IW_instance+'-description' ).val(self.IW_caption);
28
-
29
- // set alt text in widget
30
- $( '#widget-'+self.IW_instance+'-alt' ).val(self.IW_alt);
31
-
32
- // set link in widget
33
- $( '#widget-'+self.IW_instance+'-link' ).val(self.IW_url);
34
-
35
- // close thickbox
36
- tb_remove();
37
-
38
- // change button text
39
- $('#add_image-widget-'+self.IW_instance+'-image').html($('#add_image-widget-'+self.IW_instance+'-image').html().replace(/Add Image/g, 'Change Image'));
40
- },
41
-
42
- changeImgWidth : function(instance) {
43
- var width = $( '#widget-'+instance+'-width' ).val();
44
- var height = Math.round(width / imageWidget.imgRatio(instance));
45
- imageWidget.changeImgSize(instance,width,height);
46
- },
47
-
48
- changeImgHeight : function(instance) {
49
- var height = $( '#widget-'+instance+'-height' ).val();
50
- var width = Math.round(height * imageWidget.imgRatio(instance));
51
- imageWidget.changeImgSize(instance,width,height);
52
- },
53
-
54
- imgRatio : function(instance) {
55
- var width_old = $( '#display-widget-'+instance+'-image img').attr('width');
56
- var height_old = $( '#display-widget-'+instance+'-image img').attr('height');
57
- var ratio = width_old / height_old;
58
- return ratio;
59
- },
60
-
61
- changeImgSize : function(instance,width,height) {
62
- if (isNaN(width) || width < 1) {
63
- $( '#widget-'+instance+'-width' ).val('');
64
- width = 'none';
65
- } else {
66
- $( '#widget-'+instance+'-width' ).val(width);
67
- width = width + 'px';
68
- }
69
- $( '#display-widget-'+instance+'-image img' ).css({
70
- 'width':width
71
- });
72
-
73
- if (isNaN(height) || height < 1) {
74
- $( '#widget-'+instance+'-height' ).val('');
75
- height = 'none';
76
- } else {
77
- $( '#widget-'+instance+'-height' ).val(height);
78
- height = height + 'px';
79
- }
80
- $( '#display-widget-'+instance+'-image img' ).css({
81
- 'height':height
82
- });
83
- },
84
-
85
- changeImgAlign : function(instance) {
86
- var align = $( '#widget-'+instance+'-align' ).val();
87
- $( '#display-widget-'+instance+'-image img' ).attr(
88
- 'class', (align == 'none' ? '' : 'align'+align)
89
- );
90
- },
91
-
92
- imgHandler : function(event) {
93
- event.preventDefault();
94
- window.send_to_editor = imageWidget.sendToEditor;
95
- tb_show("Add an Image", event.target.href, false);
96
- },
97
-
98
- setActiveWidget : function(instance_id) {
99
- self.IW_instance = instance_id;
100
- }
101
-
102
- };
103
-
104
- $(document).ready(function() {
105
- // Use new style event handling since $.fn.live() will be deprecated
106
- if ( typeof $.fn.on !== 'undefined' ) {
107
- $("#wpbody").on("click", ".thickbox-image-widget", imageWidget.imgHandler);
108
- }
109
- else {
110
- $("a.thickbox-image-widget").live('click', imageWidget.imgHandler);
111
  }
112
 
113
- // Modify thickbox link to fit window. Adapted from wp-admin\js\media-upload.dev.js.
114
- $('a.thickbox-image-widget').each( function() {
115
- var href = $(this).attr('href'), width = $(window).width(), H = $(window).height(), W = ( 720 < width ) ? 720 : width;
116
- if ( ! href ) return;
117
- href = href.replace(/&width=[0-9]+/g, '');
118
- href = href.replace(/&height=[0-9]+/g, '');
119
- $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) );
120
- });
121
- });
122
-
123
- })(jQuery);
1
+ /**
2
+ * Tribe Image Widget Javascript
3
+ * @author Modern Tribe, Inc.
4
+ * Copyright 2013.
5
+ */
6
+ jQuery(document).ready(function($){
7
+
8
+ imageWidget = {
9
+
10
+ // Call this from the upload button to initiate the upload frame.
11
+ uploader : function( widget_id, widget_id_string ) {
12
+
13
+ var frame = wp.media({
14
+ title : TribeImageWidget.frame_title,
15
+ multiple : false,
16
+ library : { type : 'image' },
17
+ button : { text : TribeImageWidget.button_title }
18
+ });
19
+
20
+ // Handle results from media manager.
21
+ frame.on('close',function( ) {
22
+ var attachments = frame.state().get('selection').toJSON();
23
+ console.log( attachments );
24
+ imageWidget.render( widget_id, widget_id_string, attachments[0] );
25
+ });
26
+
27
+ frame.open();
28
+ return false;
29
+ },
30
+
31
+ // Output Image preview and populate widget form.
32
+ render : function( widget_id, widget_id_string, attachment ) {
33
+
34
+ $("#" + widget_id_string + 'preview').html(imageWidget.imgHTML( attachment ));
35
+
36
+ $("#" + widget_id_string + 'fields').slideDown();
37
+
38
+ $("#" + widget_id_string + 'attachment_id').val(attachment.id);
39
+ $("#" + widget_id_string + 'imageurl').val(attachment.url);
40
+ $("#" + widget_id_string + 'aspect_ratio').val(attachment.width/attachment.height);
41
+ $("#" + widget_id_string + 'width').val(attachment.width);
42
+ $("#" + widget_id_string + 'height').val(attachment.height);
43
+
44
+ $("#" + widget_id_string + 'size').val('full');
45
+ $("#" + widget_id_string + 'custom_size_selector').slideDown();
46
+ imageWidget.toggleSizes( widget_id, widget_id_string );
47
+
48
+ imageWidget.updateInputIfEmpty( widget_id_string, 'title', attachment.title );
49
+ imageWidget.updateInputIfEmpty( widget_id_string, 'alt', attachment.alt );
50
+ imageWidget.updateInputIfEmpty( widget_id_string, 'description', attachment.description );
51
+ // attempt to populate 'description' with caption if description is blank.
52
+ imageWidget.updateInputIfEmpty( widget_id_string, 'description', attachment.caption );
53
+ },
54
+
55
+ // Update input fields if it is empty
56
+ updateInputIfEmpty : function( widget_id_string, name, value ) {
57
+ var field = $("#" + widget_id_string + name);
58
+ if ( field.val() == '' ) {
59
+ field.val(value);
60
+ }
61
+ },
62
+
63
+ // Render html for the image.
64
+ imgHTML : function( attachment ) {
65
+ var img_html = '<img src="' + attachment.url + '" ';
66
+ img_html += 'width="' + attachment.width + '" ';
67
+ img_html += 'height="' + attachment.height + '" ';
68
+ if ( attachment.alt != '' ) {
69
+ img_html += 'alt="' + attachment.alt + '" ';
70
+ }
71
+ img_html += '/>';
72
+ return img_html;
73
+ },
74
+
75
+ // Hide or display the WordPress image size fields depending on if 'Custom' is selected.
76
+ toggleSizes : function( widget_id, widget_id_string ) {
77
+ if ( $( '#' + widget_id_string + 'size' ).val() == 'tribe_image_widget_custom' ) {
78
+ $( '#' + widget_id_string + 'custom_size_fields').slideDown();
79
+ } else {
80
+ $( '#' + widget_id_string + 'custom_size_fields').slideUp();
81
+ }
82
+ },
83
+
84
+ // Update the image height based on the image width.
85
+ changeImgWidth : function( widget_id, widget_id_string ) {
86
+ var aspectRatio = $("#" + widget_id_string + 'aspect_ratio').val();
87
+ if ( aspectRatio ) {
88
+ var width = $( '#' + widget_id_string + 'width' ).val();
89
+ var height = Math.round( width / aspectRatio );
90
+ $( '#' + widget_id_string + 'height' ).val(height);
91
+ //imageWidget.changeImgSize( widget_id, widget_id_string, width, height );
92
+ }
93
+ },
94
+
95
+ // Update the image width based on the image height.
96
+ changeImgHeight : function( widget_id, widget_id_string ) {
97
+ var aspectRatio = $("#" + widget_id_string + 'aspect_ratio').val();
98
+ if ( aspectRatio ) {
99
+ var height = $( '#' + widget_id_string + 'height' ).val();
100
+ var width = Math.round( height * aspectRatio );
101
+ $( '#' + widget_id_string + 'width' ).val(width);
102
+ //imageWidget.changeImgSize( widget_id, widget_id_string, width, height );
103
+ }
 
 
 
 
 
 
 
104
  }
105
 
106
+ };
107
+
108
+ });
 
 
 
 
 
 
 
 
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file
screenshot-3.png CHANGED
Binary file
views/widget-admin.deprecated.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Deprecated Widget admin template
4
+ */
5
+
6
+ // Block direct requests
7
+ if ( !defined('ABSPATH') )
8
+ die('-1');
9
+ ?>
10
+ <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', 'image_widget'); ?>:</label>
11
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['title'])); ?>" /></p>
12
+
13
+ <p><label for="<?php echo $this->get_field_id('image'); ?>"><?php _e('Image', 'image_widget'); ?>:</label>
14
+ <?php
15
+ $media_upload_iframe_src = "media-upload.php?type=image&post_id=0&widget_id=".$this->id; //NOTE #1: the widget id is added here to allow uploader to only return array if this is used with image widget so that all other uploads are not harmed.
16
+ $image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src");
17
+ $image_title = (!empty($instance['image'])) ? __('Change Image', 'image_widget') : __('Add Image', 'image_widget');
18
+ ?><br />
19
+ <a href="<?php echo $image_upload_iframe_src; ?>&TB_iframe=true" id="add_image-<?php echo $this->get_field_id('image'); ?>" class="thickbox-image-widget" title='<?php echo $image_title; ?>' onClick="imageWidget.setActiveWidget('<?php echo $this->id; ?>');return false;" style="text-decoration:none"><img src='images/media-button-image.gif' alt='<?php echo $image_title; ?>' align="absmiddle" /> <?php echo $image_title; ?></a>
20
+ <div id="display-<?php echo $this->get_field_id('image'); ?>"><?php echo $this->get_image_html($instance); ?></div>
21
+ <br clear="all" />
22
+ <input id="<?php echo $this->get_field_id('image'); ?>" name="<?php echo $this->get_field_name('image'); ?>" type="hidden" value="<?php echo $instance['image']; ?>" />
23
+ </p>
24
+
25
+ <p><label for="<?php echo $this->get_field_id('description'); ?>"><?php _e('Caption', 'image_widget'); ?>:</label>
26
+ <textarea rows="8" class="widefat" id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>"><?php echo format_to_edit($instance['description']); ?></textarea></p>
27
+
28
+ <p><label for="<?php echo $this->get_field_id('link'); ?>"><?php _e('Link', 'image_widget'); ?>:</label>
29
+ <input class="widefat" id="<?php echo $this->get_field_id('link'); ?>" name="<?php echo $this->get_field_name('link'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['link'])); ?>" /><br />
30
+ <select name="<?php echo $this->get_field_name('linktarget'); ?>" id="<?php echo $this->get_field_id('linktarget'); ?>">
31
+ <option value="_self"<?php selected( $instance['linktarget'], '_self' ); ?>><?php _e('Stay in Window', 'image_widget'); ?></option>
32
+ <option value="_blank"<?php selected( $instance['linktarget'], '_blank' ); ?>><?php _e('Open New Window', 'image_widget'); ?></option>
33
+ </select></p>
34
+
35
+ <p><label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width', 'image_widget'); ?>:</label>
36
+ <input id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['width'])); ?>" onchange="imageWidget.changeImgWidth('<?php echo $this->id; ?>')" /></p>
37
+
38
+ <p><label for="<?php echo $this->get_field_id('height'); ?>"><?php _e('Height', 'image_widget'); ?>:</label>
39
+ <input id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['height'])); ?>" onchange="imageWidget.changeImgHeight('<?php echo $this->id; ?>')" /></p>
40
+
41
+ <p><label for="<?php echo $this->get_field_id('align'); ?>"><?php _e('Align', 'image_widget'); ?>:</label>
42
+ <select name="<?php echo $this->get_field_name('align'); ?>" id="<?php echo $this->get_field_id('align'); ?>" onchange="imageWidget.changeImgAlign('<?php echo $this->id; ?>')">
43
+ <option value="none"<?php selected( $instance['align'], 'none' ); ?>><?php _e('none', 'image_widget'); ?></option>
44
+ <option value="left"<?php selected( $instance['align'], 'left' ); ?>><?php _e('left', 'image_widget'); ?></option>
45
+ <option value="center"<?php selected( $instance['align'], 'center' ); ?>><?php _e('center', 'image_widget'); ?></option>
46
+ <option value="right"<?php selected( $instance['align'], 'right' ); ?>><?php _e('right', 'image_widget'); ?></option>
47
+ </select></p>
48
+
49
+ <p><label for="<?php echo $this->get_field_id('alt'); ?>"><?php _e('Alternate Text', 'image_widget'); ?>:</label>
50
+ <input id="<?php echo $this->get_field_id('alt'); ?>" name="<?php echo $this->get_field_name('alt'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['alt'])); ?>" /></p>
views/widget-admin.php CHANGED
@@ -1,65 +1,81 @@
1
  <?php
2
  /**
3
- * Widget admin template
4
  */
5
 
6
  // Block direct requests
7
  if ( !defined('ABSPATH') )
8
  die('-1');
9
- ?>
10
- <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'image_widget'); ?></label>
11
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['title'])); ?>" /></p>
12
 
13
- <p><label for="<?php echo $this->get_field_id('image'); ?>"><?php _e('Image:', 'image_widget'); ?></label>
14
- <?php
15
- $media_upload_iframe_src = "media-upload.php?type=image&post_id=0&widget_id=".$this->id; //NOTE #1: the widget id is added here to allow uploader to only return array if this is used with image widget so that all other uploads are not harmed.
16
- $image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src");
17
- $image_title = __(($instance['image'] ? 'Change Image' : 'Add Image'), 'image_widget');
18
- ?><br />
19
- <a href="<?php echo $image_upload_iframe_src; ?>&TB_iframe=true" id="add_image-<?php echo $this->get_field_id('image'); ?>" class="thickbox-image-widget" title='<?php echo $image_title; ?>' onClick="imageWidget.setActiveWidget('<?php echo $this->id; ?>');return false;" style="text-decoration:none"><img src='images/media-button-image.gif' alt='<?php echo $image_title; ?>' align="absmiddle" /> <?php echo $image_title; ?></a>
20
- <div id="display-<?php echo $this->get_field_id('image'); ?>"><?php
21
- if ($instance['imageurl']) {
22
- echo "<img src=\"{$instance['imageurl']}\" alt=\"{$instance['title']}\" style=\"";
23
- if ($instance['width'] && is_numeric($instance['width'])) {
24
- echo "max-width: {$instance['width']}px;";
25
- }
26
- if ($instance['height'] && is_numeric($instance['height'])) {
27
- echo "max-height: {$instance['height']}px;";
28
- }
29
- echo "\"";
30
- if (!empty($instance['align']) && $instance['align'] != 'none') {
31
- echo " class=\"align{$instance['align']}\"";
32
- }
33
- echo " />";
34
- }
35
- ?></div>
36
  <br clear="all" />
37
- <input id="<?php echo $this->get_field_id('image'); ?>" name="<?php echo $this->get_field_name('image'); ?>" type="hidden" value="<?php echo $instance['image']; ?>" />
38
- </p>
39
 
40
- <p><label for="<?php echo $this->get_field_id('description'); ?>"><?php _e('Caption:', 'image_widget'); ?></label>
41
- <textarea rows="8" class="widefat" id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>"><?php echo format_to_edit($instance['description']); ?></textarea></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
- <p><label for="<?php echo $this->get_field_id('link'); ?>"><?php _e('Link:', 'image_widget'); ?></label>
44
- <input class="widefat" id="<?php echo $this->get_field_id('link'); ?>" name="<?php echo $this->get_field_name('link'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['link'])); ?>" /><br />
45
- <select name="<?php echo $this->get_field_name('linktarget'); ?>" id="<?php echo $this->get_field_id('linktarget'); ?>">
46
- <option value="_self"<?php selected( $instance['linktarget'], '_self' ); ?>><?php _e('Stay in Window', 'image_widget'); ?></option>
47
- <option value="_blank"<?php selected( $instance['linktarget'], '_blank' ); ?>><?php _e('Open New Window', 'image_widget'); ?></option>
48
- </select></p>
49
 
50
- <p><label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width:', 'image_widget'); ?></label>
51
- <input id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['width'])); ?>" onchange="imageWidget.changeImgWidth('<?php echo $this->id; ?>')" /></p>
52
 
53
- <p><label for="<?php echo $this->get_field_id('height'); ?>"><?php _e('Height:', 'image_widget'); ?></label>
54
- <input id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['height'])); ?>" onchange="imageWidget.changeImgHeight('<?php echo $this->id; ?>')" /></p>
55
 
56
- <p><label for="<?php echo $this->get_field_id('align'); ?>"><?php _e('Align:', 'image_widget'); ?></label>
57
- <select name="<?php echo $this->get_field_name('align'); ?>" id="<?php echo $this->get_field_id('align'); ?>" onchange="imageWidget.changeImgAlign('<?php echo $this->id; ?>')">
58
- <option value="none"<?php selected( $instance['align'], 'none' ); ?>><?php _e('none', 'image_widget'); ?></option>
59
- <option value="left"<?php selected( $instance['align'], 'left' ); ?>><?php _e('left', 'image_widget'); ?></option>
60
- <option value="center"<?php selected( $instance['align'], 'center' ); ?>><?php _e('center', 'image_widget'); ?></option>
61
- <option value="right"<?php selected( $instance['align'], 'right' ); ?>><?php _e('right', 'image_widget'); ?></option>
62
- </select></p>
63
 
64
- <p><label for="<?php echo $this->get_field_id('alt'); ?>"><?php _e('Alternate Text:', 'image_widget'); ?></label>
65
- <input id="<?php echo $this->get_field_id('alt'); ?>" name="<?php echo $this->get_field_name('alt'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['alt'])); ?>" /></p>
 
 
 
 
 
 
1
  <?php
2
  /**
3
+ * Image widget admin template
4
  */
5
 
6
  // Block direct requests
7
  if ( !defined('ABSPATH') )
8
  die('-1');
 
 
 
9
 
10
+ $id_prefix = $this->get_field_id('');
11
+ ?>
12
+ <div class="uploader">
13
+ <input type="submit" class="button" name="<?php echo $this->get_field_name('uploader_button'); ?>" id="<?php echo $this->get_field_id('uploader_button'); ?>" value="<?php _e('Select an Image', 'tribe-upload-tester'); ?>" onclick="imageWidget.uploader( '<?php echo $this->id; ?>', '<?php echo $id_prefix; ?>' ); return false;" />
14
+ <div class="tribe_preview" id="<?php echo $this->get_field_id('preview'); ?>">
15
+ <?php echo $this->get_image_html($instance, false); ?>
16
+ </div>
17
+ <input type="hidden" id="<?php echo $this->get_field_id('attachment_id'); ?>" name="<?php echo $this->get_field_name('attachment_id'); ?>" value="<?php echo abs($instance['attachment_id']); ?>" />
18
+ <input type="hidden" id="<?php echo $this->get_field_id('imageurl'); ?>" name="<?php echo $this->get_field_name('imageurl'); ?>" value="<?php echo $instance['imageurl']; ?>" />
19
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  <br clear="all" />
 
 
21
 
22
+ <div id="<?php echo $this->get_field_id('fields'); ?>" <?php if ( empty($instance['attachment_id']) && empty($instance['imageurl']) ) { ?>style="display:none;"<?php } ?>>
23
+ <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', 'image_widget'); ?>:</label>
24
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['title'])); ?>" /></p>
25
+
26
+ <p><label for="<?php echo $this->get_field_id('alt'); ?>"><?php _e('Alternate Text', 'image_widget'); ?>:</label>
27
+ <input class="widefat" id="<?php echo $this->get_field_id('alt'); ?>" name="<?php echo $this->get_field_name('alt'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['alt'])); ?>" /></p>
28
+
29
+ <p><label for="<?php echo $this->get_field_id('description'); ?>"><?php _e('Caption', 'image_widget'); ?>:</label>
30
+ <textarea rows="8" class="widefat" id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>"><?php echo format_to_edit($instance['description']); ?></textarea></p>
31
+
32
+ <p><label for="<?php echo $this->get_field_id('link'); ?>"><?php _e('Link', 'image_widget'); ?>:</label>
33
+ <input class="widefat" id="<?php echo $this->get_field_id('link'); ?>" name="<?php echo $this->get_field_name('link'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['link'])); ?>" /><br />
34
+ <select name="<?php echo $this->get_field_name('linktarget'); ?>" id="<?php echo $this->get_field_id('linktarget'); ?>">
35
+ <option value="_self"<?php selected( $instance['linktarget'], '_self' ); ?>><?php _e('Stay in Window', 'image_widget'); ?></option>
36
+ <option value="_blank"<?php selected( $instance['linktarget'], '_blank' ); ?>><?php _e('Open New Window', 'image_widget'); ?></option>
37
+ </select></p>
38
+
39
+
40
+ <?php
41
+ // Backwards compatibility prior to storing attachment ids
42
+ ?>
43
+ <div id="<?php echo $this->get_field_id('custom_size_selector'); ?>" <?php if ( empty($instance['attachment_id']) && !empty($instance['imageurl']) ) { $instance['size'] = self::CUSTOM_IMAGE_SIZE_SLUG; ?>style="display:none;"<?php } ?>>
44
+ <p><label for="<?php echo $this->get_field_id('size'); ?>"><?php _e('Size', 'image_widget'); ?>:</label>
45
+ <select name="<?php echo $this->get_field_name('size'); ?>" id="<?php echo $this->get_field_id('size'); ?>" onChange="imageWidget.toggleSizes( '<?php echo $this->id; ?>', '<?php echo $id_prefix; ?>' );">
46
+ <?php
47
+ // Note: this is dumb. We shouldn't need to have to do this. There should really be a centralized function in core code for this.
48
+ $possible_sizes = apply_filters( 'image_size_names_choose', array(
49
+ 'full' => __('Full Size'),
50
+ 'thumbnail' => __('Thumbnail'),
51
+ 'medium' => __('Medium'),
52
+ 'large' => __('Large'),
53
+ ) );
54
+ $possible_sizes[self::CUSTOM_IMAGE_SIZE_SLUG] = __('Custom', 'image_widget');
55
+
56
+ foreach( $possible_sizes as $size_key => $size_label ) { ?>
57
+ <option value="<?php echo $size_key; ?>"<?php selected( $instance['size'], $size_key ); ?>><?php echo $size_label; ?></option>
58
+ <?php } ?>
59
+ </select>
60
+ </p>
61
+ </div>
62
+ <div id="<?php echo $this->get_field_id('custom_size_fields'); ?>" <?php if ( empty($instance['size']) || $instance['size']!=self::CUSTOM_IMAGE_SIZE_SLUG ) { ?>style="display:none;"<?php } ?>>
63
 
64
+ <input type="hidden" id="<?php echo $this->get_field_id('aspect_ratio'); ?>" name="<?php echo $this->get_field_name('aspect_ratio'); ?>" value="<?php echo $this->get_image_aspect_ratio( $instance ); ?>" />
 
 
 
 
 
65
 
66
+ <p><label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width', 'image_widget'); ?>:</label>
67
+ <input id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['width'])); ?>" onchange="imageWidget.changeImgWidth( '<?php echo $this->id; ?>', '<?php echo $id_prefix; ?>' )" size="3" /></p>
68
 
69
+ <p><label for="<?php echo $this->get_field_id('height'); ?>"><?php _e('Height', 'image_widget'); ?>:</label>
70
+ <input id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['height'])); ?>" onchange="imageWidget.changeImgHeight( '<?php echo $this->id; ?>', '<?php echo $id_prefix; ?>' )" size="3" /></p>
71
 
72
+ </div>
 
 
 
 
 
 
73
 
74
+ <p><label for="<?php echo $this->get_field_id('align'); ?>"><?php _e('Align', 'image_widget'); ?>:</label>
75
+ <select name="<?php echo $this->get_field_name('align'); ?>" id="<?php echo $this->get_field_id('align'); ?>">
76
+ <option value="none"<?php selected( $instance['align'], 'none' ); ?>><?php _e('none', 'image_widget'); ?></option>
77
+ <option value="left"<?php selected( $instance['align'], 'left' ); ?>><?php _e('left', 'image_widget'); ?></option>
78
+ <option value="center"<?php selected( $instance['align'], 'center' ); ?>><?php _e('center', 'image_widget'); ?></option>
79
+ <option value="right"<?php selected( $instance['align'], 'right' ); ?>><?php _e('right', 'image_widget'); ?></option>
80
+ </select></p>
81
+ </div>
views/widget.php CHANGED
@@ -9,33 +9,11 @@ if ( !defined('ABSPATH') )
9
  die('-1');
10
 
11
  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="'.$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
- }
22
- if ( !empty( $height ) && is_numeric( $height ) ) {
23
- echo "max-height: {$height}px;";
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 " />";
35
- }
36
 
37
- if ( $link ) { echo '</a>'; }
38
- }
39
  if ( !empty( $description ) ) {
40
  echo '<div class="'.$this->widget_options['classname'].'-description" >';
41
  echo wpautop( $description );
9
  die('-1');
10
 
11
  echo $before_widget;
12
+
13
  if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
+ echo $this->get_image_html( $instance, true );
16
+
17
  if ( !empty( $description ) ) {
18
  echo '<div class="'.$this->widget_options['classname'].'-description" >';
19
  echo wpautop( $description );