WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: Image Widget] Add image, upload an image select Insert into widget. No image is shown.

[Resolved] [Plugin: Image Widget] Add image, upload an image select Insert into widget. No image is shown.

  • = Problem =
    Cannot add a new image from upload to the widget using the following steps:

    = Reproduce issue =
    1) Press Add Image
    2) Upload a new image using browser upload, the uploading works fine as the image can be found in the Media Library.
    3) Press ‘Insert into Widget’
    4) No image is shown in the widget, but the ‘Add image’ has changed into ‘Change Image’.

    Instead of uploading a new image you’d select an image from the Media Library the widget does work as expected and displays an image after selecting ‘Insert into widget’. Also if I use the Flash based uploader instead of the browser based uploader it works as expected.

    = Enviroment =
    – WordPress Multisite (v3.2.1.) for an internal website, which at the moment cannot be upgraded to WordPress 3.3.
    – PHP version is PHP 5.3.5-1ubuntu7.4 with Suhosin-Patch.
    – Browsers used:
    Chrome 16.0.912.77 (Developer Build 118311) Ubuntu 11.04
    Firefox 10
    IE 7
    – Image Widget v3.2.11

    http://wordpress.org/extend/plugins/image-widget/

Viewing 15 replies - 1 through 15 (of 23 total)
  • I’m also looking for the solutions of this issue…i’m facing troubles with flash uploader under SSL connection but, actually, browser uploader dosen’t help

    I think I’ve found the issue:

    The image-widget code uses a function is_sp_widget_context() (in image-widget.php line 106) which makes sure the image-widget code only runs in the context of the Image Widget. It does this by checking if the http referer or _wp_http_referer contains ‘widget_sp_image’.
    WordPress uses a variable widget_id when using the media library and when using the Flash uploader (see the referer urls), however it does not use this variable when uploading through the browser based form, which I presume might be a bug in WordPress 3.2.1 (haven’t checked later versions).

    Actually the widget_id seems to be set by the image-widget in /views/admin-widget.php

    I’ve solved this issue with a bit of Javascript. I have described the problem more detailed on my own site including the solution. Check it out here:

    http://www.burobjorn.nl/blog/2012/02/08/howto-fix-wordpress-image-widget-plugins-html-form-based-uploads/

    Update: The guys from Modern Tribe have included my proposed fix (in Image Widget 3.3.x) and thus my patched version is not needed anymore.

    Hi,

    I’m still seeing this issue with 3.3.4 of the widget.

    Uploading a fresh copy of the image is a work around for me.

    Just thought I would mention it in case anyone else is having the problem.

    Running it on a networked site with wp version 3.3.2

    Jason

    Jason,

    Could you describe exactly what you are doing (similar to my first post) and which browser you are using? This makes it possible to reproduce the issue so it can be fixed. Thanks!

    1) Press Add Image
    2) Upload a new image using flash upload, the uploading works fine as the image can be found in the Media Library.
    3) Press ‘Insert into Widget’
    4) No image is shown in the widget, but the ‘Add image’ has changed into ‘Change Image’.

    note” same steps as you were making, only I used the flash uploader.

    This is in Chrome on OSX. not sure of the version, but current stable as it updates itself.

    Also on a multi site install.

    Hope that helps?

    Jason

    I have found if you use the month filter or the search functionality in the media library it fails to insert / update the image in the widget.

    I have precisely the same problem using latest version wordpress + latest version this widget (v3.3.4). problem occurs when using either ‘filter by date’ or ‘search’ functions in the ‘select from media library’ tab.

    (retesting shows prob also existed on v3.2.11)

    anyone worked out a fix?

    I’m having the same issue with the library when using search or date filter. It’s the same as BjornW was talking about regarding the widget_id missing.

    $_SERVER['HTTP_REFERER'] === '.../wp-admin/media-upload.php?type=image&tab=library&post_id=0&post_mime_type=&context=&s=sebb&m=0'

    $this->base_id === 'widget_sp_image'

    $_REQUEST['_wp_http_referer'] === '/wp-admin/media-upload.php?type=image&tab=library&post_id=0&post_mime_type=&context=&s=sebb&m=0'

    $_REQUEST['widget_id'] === NULL

    Because of this is_sp_widget_context() returns false in image_send_to_editor and so does function does not output the required JS globals.

    Unfortunately I’ve never written code for WP so I’m not sure how to fix this issue.

    I fixed this by adding the following code to js/image-widget-fix-browser-upload.js (this is in version 3.3.4), after line 20:

    //also update the filter form with a new hidden field
      //is the filter form present on the page?
      if (jQuery("form#filter").length>0) {
    
              //code for retrieving GET vars (we want the value of widget_id)
    	  var $_GET = {};
    	  document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
    	      function decode(s) {
    	          return decodeURIComponent(s.split("+").join(" "));
    	      }
    
    	      $_GET[decode(arguments[1])] = decode(arguments[2]);
    	  });
    
    	  var theid = $_GET['widget_id'];
    	  if (theid.length > 0) {//do we have a value?
    
    		  //insert hidden field into form
    		  jQuery('form#filter').append(
    				  jQuery('<input/>')
    			            .attr('type', 'hidden')
    			            .attr('name', 'widget_id')
    			            .val(theid)
    		  );
    	  }
      }

    The file name is image-widget-upload-fixer.js ; but this fix worked for me. Thanks much @miraclemaker!

    You’re welcome. Hopefully they’ll fix this in the next version.

    I used the widget in several site with no problem on v.3.4.1 of WP. Suddenly, on my final site the image is not showing with the same problem as indicated in the original post. Changes add image to change image.

    I deactivated the image and reinstalled it with the same problem.

    Odd how it was working fine than poof.

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘[Resolved] [Plugin: Image Widget] Add image, upload an image select Insert into widget. No image is shown.’ is closed to new replies.