WordPress.org

Ready to get started?Download WordPress

Forums

Image Widget
[resolved] Add image, upload an image select Insert into widget. No image is shown. (24 posts)

  1. BjornW
    Member
    Posted 2 years ago #

    = 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/

  2. trustweb.ms
    Member
    Posted 2 years ago #

    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

  3. BjornW
    Member
    Posted 2 years ago #

    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).

  4. BjornW
    Member
    Posted 2 years ago #

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

  5. BjornW
    Member
    Posted 2 years ago #

    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/

  6. BjornW
    Member
    Posted 2 years ago #

    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.

  7. Jason Lewis
    Member
    Posted 1 year ago #

    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

  8. BjornW
    Member
    Posted 1 year ago #

    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!

  9. Jason Lewis
    Member
    Posted 1 year ago #

    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

  10. miraclemaker
    Member
    Posted 1 year ago #

    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.

  11. rcain
    Member
    Posted 1 year ago #

    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?

  12. oxyc
    Member
    Posted 1 year ago #

    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.

  13. miraclemaker
    Member
    Posted 1 year ago #

    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)
    		  );
    	  }
      }
  14. worldwisewebs
    Member
    Posted 1 year ago #

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

  15. miraclemaker
    Member
    Posted 1 year ago #

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

  16. Don
    Member
    Posted 1 year ago #

    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.

  17. Don
    Member
    Posted 1 year ago #

    I placed the code in at line 22 as 20 had some code but I'm not getting an image yet.

  18. mahlinksi
    Member
    Posted 1 year ago #

    I have the exact same problem.
    I have a multisite solution and trying to add an image in this widget.
    No success though, the recommended code is not working for me.
    The image doesn't show, and when i click 'save', 'change image' changes to 'add image'.

  19. weetouches
    Member
    Posted 1 year ago #

    I had 3 web site with image widget plugin

    1 with WP 3.4.1 and Image widget 3.3.4 --> Not working
    1 with wp 3.4 and Image widget 3.3.4 -->Not working

    and

    1 with wp 3.2.1 and Image widget 3.3.4 --> WORKING GREAT

    I think there's an bug between WP 3.4 and and Image widget 3.3.4.

    If you loaded your image in your widget before upgrading wordpress your widget still working but if you want to add another image widget box after upgrading WordPress the bugs happens..

  20. Floristeady
    Member
    Posted 1 year ago #

    I have the same problem too.
    WP 3.4.1 and Image Widget 3.3.4.

    I add the image but does not work, no error or nothing appears.

  21. Peter Chester
    Modern Tribe
    Plugin Author

    Posted 1 year ago #

    @miraclemaker - your awesome fix works great!
    @everyone - thank you for all this great feedback. I just deployed 3.3.5 with some fixes. I'm going to mark this ticket as resolved even though there are some recent updates since they seem to be a different issue (that i can't reproduce)

    @Don, @mahlinksi - if you wouldn't mind, please open a new thread for the issues you just described and add some details about your installs:
    * WordPress Version
    * is this plugin Mu activated or activated per site
    * Domain mapping turned on? Does this happen on sites without domain mapping?
    * Any other tips I might be able to use to debug this

  22. hbond
    Member
    Posted 1 year ago #

    I have Version 3.3.7 and experiencing the same problem, i.e., the image does not load. The code that's referenced above is in the new version, correct?

  23. hbond
    Member
    Posted 1 year ago #

    I finally found the problem. I had another image Widget (Rotator) install. FOr some reason, the code was conflicting with this Image Widget. I deleted the other widget that I wasn't using and presto..... This one now works!!!!

  24. Peter Chester
    Modern Tribe
    Plugin Author

    Posted 1 year ago #

    Yay!!!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic