Simple Image Widget - Version 2.1

Version Description

Download this release

Release Info

Developer vickio
Plugin Icon 128x128 Simple Image Widget
Version 2.1
Comparing to
See all releases

Code changes from version 2.0 to 2.1

Files changed (3) hide show
  1. readme.txt +5 -4
  2. screenshot-1.png +0 -0
  3. simpleimage.php +16 -6
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: vickio
3
  Donate link: http://vickio.net
4
  Tags: image, sidebar, widget, photo, picture
5
  Requires at least: 2.8
6
- Tested up to: 3.1.1
7
- Stable tag: 2.0
8
 
9
  The simple way to place images in your sidebars.
10
 
@@ -15,9 +15,10 @@ Using this widget you can easily place an image in the sidebar. You can also spe
15
  Once the plugin is enabled, the widget will be available in your widgets list as "Simple Image". You can add this widget to sidebars as many times as you need. The control interface allows you to specify the following options for each instance of the widget:
16
 
17
  * Image URL: The full URL to the image file
18
- * Alternate Text: Shown by the browser if image cannot be displayed
 
19
  * Link URL: URL to open when the image is clicked on (optional)
20
- * Open link in new window: If this is checked, the above link URL will open in a new browser window
21
 
22
  == Installation ==
23
 
3
  Donate link: http://vickio.net
4
  Tags: image, sidebar, widget, photo, picture
5
  Requires at least: 2.8
6
+ Tested up to: 3.2.1
7
+ Stable tag: 2.1
8
 
9
  The simple way to place images in your sidebars.
10
 
15
  Once the plugin is enabled, the widget will be available in your widgets list as "Simple Image". You can add this widget to sidebars as many times as you need. The control interface allows you to specify the following options for each instance of the widget:
16
 
17
  * Image URL: The full URL to the image file
18
+ * Alternate Text: Shown by the browser if the image cannot be displayed, or if image loading is disabled
19
+ * Title: Displayed in a tooltip when the mouse cursor is held over the image for a few seconds
20
  * Link URL: URL to open when the image is clicked on (optional)
21
+ * Open link in new window: If this is enabled, the link will open in a new browser window
22
 
23
  == Installation ==
24
 
screenshot-1.png CHANGED
Binary file
simpleimage.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Simple Image Widget
4
  Description: Using this widget you can easily place an image and link in the sidebar. It supports multiple instances, so you can use it multiple times in multiple sidebars.
5
- Version: 2.0
6
  Author: Chris Vickio
7
  Author URI: http://vickio.net
8
  */
@@ -54,7 +54,7 @@ class WP_Widget_Simple_Image extends WP_Widget {
54
  echo $before_widget; ?>
55
  <div class="simpleimage">
56
  <?php echo $before_image; ?>
57
- <img src="<?php echo $instance['image']; ?>" alt="<?php echo $instance['alt']; ?>" />
58
  <?php echo $after_image; ?>
59
  </div>
60
  <?php echo $after_widget;
@@ -65,6 +65,7 @@ class WP_Widget_Simple_Image extends WP_Widget {
65
  $instance = $old_instance;
66
  $instance['image'] = strip_tags($new_instance['image']);
67
  $instance['alt'] = strip_tags($new_instance['alt']);
 
68
  $instance['link'] = strip_tags($new_instance['link']);
69
  $instance['new_window'] = isset($new_instance['new_window']);
70
  return $instance;
@@ -72,7 +73,7 @@ class WP_Widget_Simple_Image extends WP_Widget {
72
 
73
  // Display the widget form in the admin interface
74
  function form( $instance ) {
75
- $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'image' => '', 'alt' => '', 'link' => '', 'new_window' => false ) );
76
 
77
  // Generate a title based on the image URL
78
  if ($instance['image'])
@@ -84,7 +85,7 @@ class WP_Widget_Simple_Image extends WP_Widget {
84
 
85
  <p>
86
  <label for="<?php echo $this->get_field_id('image'); ?>">
87
- <?php _e('Image URL:'); ?>
88
  <input class="widefat" id="<?php echo $this->get_field_id('image'); ?>" name="<?php echo $this->get_field_name('image'); ?>" type="text" value="<?php echo $instance['image']; ?>" />
89
  </label>
90
  </p>
@@ -94,13 +95,22 @@ class WP_Widget_Simple_Image extends WP_Widget {
94
  <?php _e('Alternate Text:'); ?>
95
  <input class="widefat" id="<?php echo $this->get_field_id('alt'); ?>" name="<?php echo $this->get_field_name('alt'); ?>" type="text" value="<?php echo $instance['alt']; ?>" />
96
  <br />
97
- <small><?php _e( 'Shown if image cannot be displayed' ); ?></small>
 
 
 
 
 
 
 
 
 
98
  </label>
99
  </p>
100
 
101
  <p>
102
  <label for="<?php echo $this->get_field_id('link'); ?>">
103
- <?php _e('Link URL (optional):'); ?>
104
  <input class="widefat" id="<?php echo $this->get_field_id('link'); ?>" name="<?php echo $this->get_field_name('link'); ?>" type="text" value="<?php echo $instance['link']; ?>" />
105
  </label>
106
  </p>
2
  /*
3
  Plugin Name: Simple Image Widget
4
  Description: Using this widget you can easily place an image and link in the sidebar. It supports multiple instances, so you can use it multiple times in multiple sidebars.
5
+ Version: 2.1
6
  Author: Chris Vickio
7
  Author URI: http://vickio.net
8
  */
54
  echo $before_widget; ?>
55
  <div class="simpleimage">
56
  <?php echo $before_image; ?>
57
+ <img src="<?php echo $instance['image']; ?>" alt="<?php echo $instance['alt']; ?>" title="<?php echo $instance['img_title']; ?>" />
58
  <?php echo $after_image; ?>
59
  </div>
60
  <?php echo $after_widget;
65
  $instance = $old_instance;
66
  $instance['image'] = strip_tags($new_instance['image']);
67
  $instance['alt'] = strip_tags($new_instance['alt']);
68
+ $instance['img_title'] = strip_tags($new_instance['img_title']);
69
  $instance['link'] = strip_tags($new_instance['link']);
70
  $instance['new_window'] = isset($new_instance['new_window']);
71
  return $instance;
73
 
74
  // Display the widget form in the admin interface
75
  function form( $instance ) {
76
+ $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'image' => '', 'alt' => '', 'img_title' => '', 'link' => '', 'new_window' => false ) );
77
 
78
  // Generate a title based on the image URL
79
  if ($instance['image'])
85
 
86
  <p>
87
  <label for="<?php echo $this->get_field_id('image'); ?>">
88
+ <?php _e('Image URL (required):'); ?>
89
  <input class="widefat" id="<?php echo $this->get_field_id('image'); ?>" name="<?php echo $this->get_field_name('image'); ?>" type="text" value="<?php echo $instance['image']; ?>" />
90
  </label>
91
  </p>
95
  <?php _e('Alternate Text:'); ?>
96
  <input class="widefat" id="<?php echo $this->get_field_id('alt'); ?>" name="<?php echo $this->get_field_name('alt'); ?>" type="text" value="<?php echo $instance['alt']; ?>" />
97
  <br />
98
+ <small><?php _e( 'Shown if the image cannot be displayed' ); ?></small>
99
+ </label>
100
+ </p>
101
+
102
+ <p>
103
+ <label for="<?php echo $this->get_field_id('img_title'); ?>">
104
+ <?php _e('Title:'); ?>
105
+ <input class="widefat" id="<?php echo $this->get_field_id('img_title'); ?>" name="<?php echo $this->get_field_name('img_title'); ?>" type="text" value="<?php echo $instance['img_title']; ?>" />
106
+ <br />
107
+ <small><?php _e( 'Shown when the mouse cursor is held over the image' ); ?></small>
108
  </label>
109
  </p>
110
 
111
  <p>
112
  <label for="<?php echo $this->get_field_id('link'); ?>">
113
+ <?php _e('Link URL:'); ?>
114
  <input class="widefat" id="<?php echo $this->get_field_id('link'); ?>" name="<?php echo $this->get_field_name('link'); ?>" type="text" value="<?php echo $instance['link']; ?>" />
115
  </label>
116
  </p>