Menu Image - Version 2.1

Version Description

  • Fix http://wordpress.org/support/topic/set-image-button-not-working
  • Fix http://wordpress.org/support/topic/vertical-align-when-using-mouseover-image
Download this release

Release Info

Developer zviryatko
Plugin Icon 128x128 Menu Image
Version 2.1
Comparing to
See all releases

Code changes from version 2.0 to 2.1

Files changed (4) hide show
  1. menu-image-admin.js +4 -4
  2. menu-image.css +7 -24
  3. menu-image.php +10 -11
  4. readme.txt +5 -1
menu-image-admin.js CHANGED
@@ -12,8 +12,8 @@
12
  });
13
  };
14
 
15
- $('#menu-to-edit').find('.menu-item')
16
- .on('click', '.set-post-thumbnail', function (e) {
17
  e.preventDefault();
18
  e.stopPropagation();
19
 
@@ -21,14 +21,14 @@
21
  is_hover = $(this).hasClass('hover-image'),
22
  uploader = wp.media({
23
  title: menuImage.l10n.uploaderTitle, // todo: translate
24
- button: { text: 'Select' },
25
  multiple: false
26
  }).on('select', function () {
27
  var attachment = uploader.state().get('selection').first().toJSON();
28
  menuImageUpdate( item_id, attachment.id, is_hover );
29
  }).open();
30
  })
31
- .on('click', '.remove-post-thumbnail', function (e) {
32
  e.preventDefault();
33
  e.stopPropagation();
34
 
12
  });
13
  };
14
 
15
+ $('#menu-to-edit')
16
+ .on('click', '.menu-item .set-post-thumbnail', function (e) {
17
  e.preventDefault();
18
  e.stopPropagation();
19
 
21
  is_hover = $(this).hasClass('hover-image'),
22
  uploader = wp.media({
23
  title: menuImage.l10n.uploaderTitle, // todo: translate
24
+ button: { text: menuImage.l10n.uploaderButtonText },
25
  multiple: false
26
  }).on('select', function () {
27
  var attachment = uploader.state().get('selection').first().toJSON();
28
  menuImageUpdate( item_id, attachment.id, is_hover );
29
  }).open();
30
  })
31
+ .on('click', '.menu-item .remove-post-thumbnail', function (e) {
32
  e.preventDefault();
33
  e.stopPropagation();
34
 
menu-image.css CHANGED
@@ -2,38 +2,21 @@
2
  border: none;
3
  box-shadow: none;
4
  vertical-align: middle;
 
5
  }
6
- .menu-item a .menu-image-hover-wrapper {
7
- display: block;
8
- overflow: hidden;
9
- }
10
- .menu-item a .menu-image-hover-wrapper,
11
- .menu-item a .menu-image-hover-wrapper img {
12
- float: left;
13
- }
14
- .menu-item a.menu-image-hovered .menu-image-hover-wrapper img.hovered-image,
15
- .menu-item a.menu-image-hovered:hover .menu-image-hover-wrapper img.menu-image {
16
  opacity: 0;
 
17
  }
18
- .menu-item a.menu-image-hovered:hover .menu-image-hover-wrapper img.hovered-image {
19
  opacity: 1;
20
  }
21
- .menu-item a.menu-image-title-hide .menu-image-hover-wrapper,
22
- .menu-item a.menu-image-title-before .menu-image-hover-wrapper {
23
- vertical-align: top;
24
- display: inline-block;
25
- float: none;
26
- }
27
- .menu-item a.menu-image-title-after img,
28
  .menu-item a.menu-image-hovered.menu-image-title-after .menu-image-hover-wrapper {
29
  padding-right: 10px;
30
  }
31
- .menu-item a.menu-image-title-before img,
32
  .menu-item a.menu-image-hovered.menu-image-title-before .menu-image-hover-wrapper {
33
  padding-left: 10px;
34
- }
35
- .menu-item a .menu-image-hover-wrapper img {
36
- padding: 0;
37
- position: absolute;
38
- transition: opacity 0.25s ease-in-out 0s;
39
  }
2
  border: none;
3
  box-shadow: none;
4
  vertical-align: middle;
5
+ width: auto;
6
  }
7
+ .menu-item a.menu-image-hovered img.hovered-image,
8
+ .menu-item a.menu-image-hovered:hover img.menu-image {
 
 
 
 
 
 
 
 
9
  opacity: 0;
10
+ transition: opacity 0.25s ease-in-out 0s;
11
  }
12
+ .menu-item a.menu-image-hovered:hover img.hovered-image {
13
  opacity: 1;
14
  }
15
+ .menu-item a.menu-image-title-after.menu-image-not-hovered img,
 
 
 
 
 
 
16
  .menu-item a.menu-image-hovered.menu-image-title-after .menu-image-hover-wrapper {
17
  padding-right: 10px;
18
  }
19
+ .menu-item a.menu-image-title-before.menu-image-not-hovered img,
20
  .menu-item a.menu-image-hovered.menu-image-title-before .menu-image-hover-wrapper {
21
  padding-left: 10px;
 
 
 
 
 
22
  }
menu-image.php CHANGED
@@ -10,7 +10,7 @@ Plugin Name: Menu Image
10
  Plugin URI: http://html-and-cms.com/plugins/menu-image/
11
  Description: Provide uploading images to menu item
12
  Author: Alex Davyskiba aka Zviryatko
13
- Version: 2.0
14
  Author URI: http://makeyoulivebetter.org.ua/
15
  */
16
 
@@ -173,20 +173,18 @@ class Menu_Image_Plugin {
173
  $class = "menu-image-title-{$position}";
174
  if ( $item->thumbnail_hover_id ) {
175
  $hover_image_src = wp_get_attachment_image_src( $item->thumbnail_hover_id, $image_size );
176
- $style = '';
177
- if ( isset( $hover_image_src[1] ) && isset( $hover_image_src[1] ) ) {
178
- $width = $hover_image_src[1];
179
- $height = $hover_image_src[2] + 1; // +1px because span have small inline space..
180
- $style .= " style='width: {$width}px; height: {$height}px;'";
181
- $attributes .= " style='line-height: {$height}px'";
182
- }
183
- $image = "<span class='menu-image-hover-wrapper'" . $style . ">";
184
  $image .= wp_get_attachment_image( $item->thumbnail_id, $image_size, false, "class=menu-image {$class}" );
185
- $image .= wp_get_attachment_image( $item->thumbnail_hover_id, $image_size, false, "class=hovered-image {$class}" );
186
- $image .= '</span>';
 
 
 
187
  $class .= ' menu-image-hovered';
188
  } else {
189
  $image = wp_get_attachment_image( $item->thumbnail_id, $image_size, false, "class=menu-image {$class}" );
 
190
  }
191
 
192
  $item_output = "{$args->before}<a{$attributes} class='{$class}'>";
@@ -228,6 +226,7 @@ class Menu_Image_Plugin {
228
  wp_localize_script('menu-image-admin', 'menuImage', array(
229
  'l10n' => array(
230
  'uploaderTitle' => __( 'Chose menu image', 'menu-image' ),
 
231
  ),
232
  'settings' => array(
233
  'nonce' => wp_create_nonce( 'update-menu-item' ),
10
  Plugin URI: http://html-and-cms.com/plugins/menu-image/
11
  Description: Provide uploading images to menu item
12
  Author: Alex Davyskiba aka Zviryatko
13
+ Version: 2.1
14
  Author URI: http://makeyoulivebetter.org.ua/
15
  */
16
 
173
  $class = "menu-image-title-{$position}";
174
  if ( $item->thumbnail_hover_id ) {
175
  $hover_image_src = wp_get_attachment_image_src( $item->thumbnail_hover_id, $image_size );
176
+ $margin_size = $hover_image_src[1];
177
+ $image = "<span class='menu-image-hover-wrapper'>";
 
 
 
 
 
 
178
  $image .= wp_get_attachment_image( $item->thumbnail_id, $image_size, false, "class=menu-image {$class}" );
179
+ $image .= wp_get_attachment_image( $item->thumbnail_hover_id, $image_size, false, array(
180
+ 'class' => "hovered-image {$class}",
181
+ 'style' => "margin-left: -{$margin_size}px;",
182
+ ));
183
+ $image .= '</span>';;
184
  $class .= ' menu-image-hovered';
185
  } else {
186
  $image = wp_get_attachment_image( $item->thumbnail_id, $image_size, false, "class=menu-image {$class}" );
187
+ $class .= ' menu-image-not-hovered';
188
  }
189
 
190
  $item_output = "{$args->before}<a{$attributes} class='{$class}'>";
226
  wp_localize_script('menu-image-admin', 'menuImage', array(
227
  'l10n' => array(
228
  'uploaderTitle' => __( 'Chose menu image', 'menu-image' ),
229
+ 'uploaderButtonText' => __( 'Select', 'menu-image' ),
230
  ),
231
  'settings' => array(
232
  'nonce' => wp_create_nonce( 'update-menu-item' ),
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: menu, image, field, hover
4
  Donate link: http://makeyoulivebetter.org.ua/buy-beer
5
  Requires at least: 3.5.1
6
  Tested up to: 3.9.1
7
- Stable tag: 2.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -43,6 +43,10 @@ Just register another image size in your theme with function `add_image_size()`.
43
 
44
  == Changelog ==
45
 
 
 
 
 
46
  = 2.0 =
47
  * Added support of media uploader.
48
  * Fixed php strict warnings.
4
  Donate link: http://makeyoulivebetter.org.ua/buy-beer
5
  Requires at least: 3.5.1
6
  Tested up to: 3.9.1
7
+ Stable tag: 2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
43
 
44
  == Changelog ==
45
 
46
+ = 2.1 =
47
+ * Fix http://wordpress.org/support/topic/set-image-button-not-working
48
+ * Fix http://wordpress.org/support/topic/vertical-align-when-using-mouseover-image
49
+
50
  = 2.0 =
51
  * Added support of media uploader.
52
  * Fixed php strict warnings.