WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Images not Saving to Image Widget (64 posts)

  1. Peter Chester
    Modern Tribe
    Posted 4 years ago #

    I'm using wp 2.84. All the image widgets were gone from the sidebar and I've tried adding them back but when you try to add an image either from my computer or the media library it acts like it's going to add an image but when you click "insert into post" the directions box that you're working in just goes blank and then if you bypass that and click on "save all changes" it goes back to where you select an image. Either way when you go back to the widget, no image is there and when you save the widget and view page only the title is showing up, no image.

    I've deactivated the plugin and reactivated it, I've logged in and out, I even tried uninstalling the plugin and reinstalling and deactivating other widgets that use images. Not sure what to try from here.

    Thanks taking the time to respond though. :)

    Laurie

    Hi Laurie, thank you so much for the feedback. I'd very much like to help you resolve this.

    what browser are you using? What OS? Are you willing to record what happens in a screen video (I personally like using Jing for that)?

    Thanks again Laurie!

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

  2. L_T_G
    Member
    Posted 4 years ago #

    I'm using firefox and windows xp. Sure, I'll record what happens in a screen video. Will it have to be posted online though?

    Thanks for your help!

    Laurie

  3. Peter Chester
    Modern Tribe
    Posted 4 years ago #

    (no, you can email it to me and i'll follow up with comments on here)

    :)

  4. squigie
    Member
    Posted 4 years ago #

    Same problem. Click link to add image, and when I add an image either by upload, or from Library, when I insert into post no image shows up, only title if I added one. I'm using 2.8.4, and version 3.0.4 of image widget. I've deleted it, reinstalled, but it doesn't work. I've tried other versions, same problem. Any Ideas? I really want the functionality of this plugin. It looks fantastic, but alas...

  5. squigie
    Member
    Posted 4 years ago #

    New install WP 2.8.4 & new database. No other widget, or plugins, and the problem with image widget is the same. It shows up in widgets area, but it will not add the selected image. Any thoughts? Fixes?

  6. Peter Chester
    Modern Tribe
    Posted 4 years ago #

    Laurie, than you for your screencast.

    Squigie, are you on windows or mac? what browser? I'm wondering if this is a javascript issue on windows or something. It works for me every time but i'm on a mac.

  7. sweetas
    Member
    Posted 4 years ago #

    Same issue here. Running xp and wordpress 2.8.4. Have tried image widget using in firefox, explorer, chrome and opera...all with the same result as described above by Laurie.

  8. Peter Chester
    Modern Tribe
    Posted 4 years ago #

    I'm really thinking this might be a windows / javascript issue. I'm not super good at javascript and don't have windows (i'm on a mac). If anyone has javascript skills, I'd embrace the support. :)

  9. smurkas
    Member
    Posted 4 years ago #

    I'll try to help you out since I'm having this problem on my production server which is a linux system.

    Just so everyone is on the same page here, does everyone who's having issues end up with a blank thickbox when trying to add the image? I get a blank thickbox and this error in firebug:
    win.send_to_custom_field is not a function

    I don't get this error on my local windows machine that I'm doing all the development on and it's a weird javascript error if it's server related.

    I've got some javascript chops so I'll try to track this down and fix it. This widget provides some really essential functionality that wordpress has been lacking for quite some time so I'm hoping I can find what's causing this.

    If anyone else out there who's having issues could check what happens in firebug and confirm that you're getting the same error I would be very grateful.

  10. smurkas
    Member
    Posted 4 years ago #

    Oh wow what a mess (not your plugin :P).

    I have tracked this down and it appears to be a javascript conflict. In my case the conflict was with custom field template, can anyone else confirm that they get the error when using custom fields and image widget together?

    If I turn off custom field template then everything works. I am using version 1.3.7 of custom fields template, I will try it with version 1.3.8 as well.

    For anyone else tracking this, the thickbox is an iframe with its own scripts loaded. Some plugins load their scripts into the thickbox and I'm not sure if they belong there.

    Peter can you confirm if the thickbox actually needs your javascript loaded inside it or if it's only needed in the admin section?

  11. smurkas
    Member
    Posted 4 years ago #

    Ok I can confirm that the conflict is coming from custom field template. It appears that he hooks in to when the image is "transferred" from the thickbox to its final destination.

    When his code runs on the widget page it gets confused since the code he's depending on is not there, his function fails and so does your script along with it.

    I see two (maybe three) ways to fix this:

    1. The fast (and painful): Simply choose which plugin you need the most and deactivate the other one
    2. The long road: We talk to the guy who made custom field template and ask him to solve this. His plugin is very active so I think there might be a good chance that he will comply.
    3. The sneaky (and untested) solution: Hit his plugin with a remove_action() to remove the offending javascript when on the widget page. If we can make sure this plugin gets loaded after custom field template it should theoretically be possible to remove the action hook that adds his code.

    That's all the options I can come up with. I'll be exploring option three and see if I can get that to work.

  12. Peter Chester
    Modern Tribe
    Posted 4 years ago #

    smurkas! you rock! I'll tinker with that a bit tonight and see what i can find.

  13. capnhairdo
    Member
    Posted 4 years ago #

    I'm having the same problem as above...when I click to add an image, I can upload one from my computer or browse the library, but when I click to "insert into post", nothing happens.

    Smurkas, sounds like you discovered and are fixing a different problem. I don't have the Custom Field Template plug-in installed.

  14. capnhairdo
    Member
    Posted 4 years ago #

    BTW, using WP 2.8.4. Windows XP. Tried with FireFox 3, IE8, Google Chrome, Safari 4. Same result in all, except that in the last three, the "Add an Image" box just goes blank when you click "insert into post". No JavaScript errors showing up in FireFox error console.

    Thanks for checking it out!

  15. smurkas
    Member
    Posted 4 years ago #

    It sounds like the same kind of error that we're getting from the conflict with custom field template. When I have custom field template on I get the exact same behaviour.

    What plugins are you running?

    If you have the possibility it would be very appreciated if you could turn off all your other plugins and see if the problem persists. If it works without the other plugins on I would be even happier if you could help us track down the plugin that's conflicting.

    Also the javascript error could be occurring inside the thickbox which is in an iframe so in that case I don't think we'd actually get a warning from firebug :(.

  16. capnhairdo
    Member
    Posted 4 years ago #

    I tried turning off all the other plug-ins...that doesn't seem to be it.

    Strangely, it works on my development server with everything almost exactly the same as my live server.

    Problem seems to be with this line:

    if (strpos($_REQUEST['_wp_http_referer'],$this->id)) { // check that this is for the widget. SEE NOTE #1

    $this->id appears to be empty to have a value, so there's no match, and nothing is returned to the widget. Why the widget name (this->id) is disappearing, I don't know. (I don't know what NOTE #1 is, but I understand why you need to do this check--so you don't return the JavaScript array to other functions calling the image_send_to_editor() function.)

  17. capnhairdo
    Member
    Posted 4 years ago #

    On live server, the widget object is missing some values. $this->number and $this->id both return false. On my development server, I get 3 and widget_sp_image-3, respectively for those vars. Some glitch with the widget object?

  18. smurkas
    Member
    Posted 4 years ago #

    You seem to be on to something there capnhairdo.

    I tried turning off the offending javascript in custom field template and I still ended up with an empty thickbox but no javascript error.

    The weird part is that everything works on my live server if I turn off custom field template so something else is causing som kind of conflict.

  19. Peter Chester
    Modern Tribe
    Posted 4 years ago #

    I have an idea! One of the problems i encountered in writing this is that i needed to format the output de3pending on if the thickbox is being used for the widget as opposed to for a post editor. In the widget php in the function "image_send_to_editor()" I am taking the widget id and comparing it with the $_REQUEST['_wp_http_referer'].

    Could it be that windows boxes don't have a $_REQUEST['_wp_http_referer']? Do they have a $_POST['_wp_http_referer']? This is the only way i could think of to deturmine where the thickbox came from. I'm open to alternatives.

  20. Peter Chester
    Modern Tribe
    Posted 4 years ago #

    lol! I just noticed that i missed a chunk of conversation. clearly this fix is not my idea... capnhairdo had it before me. please disregard my previous comment.

  21. Peter Chester
    Modern Tribe
    Posted 4 years ago #

    capnhairdo: what version of PHP are you running on the server? locally?

  22. Peter Chester
    Modern Tribe
    Posted 4 years ago #

    Aha! This is not working in PHP4...

    Try this... replace:

    if (strpos($_REQUEST['_wp_http_referer'],$this->id)) {

    with:

    if (strpos($_REQUEST['_wp_http_referer'],$this->id_base)) {

    does that fix it? make sure and clear cache and refresh first.

  23. Peter Chester
    Modern Tribe
    Posted 4 years ago #

    I've updated that line in trunk
    http://svn.wp-plugins.org/image-widget/trunk/

  24. capnhairdo
    Member
    Posted 4 years ago #

    Windows boxes definitely have a $_REQUEST object, which includes $_POST. That's PHP, nothing to do with the platform.

    Anyway, the referer is fine. What's NOT fine is the widget object itself. Like I said, it's $this->id that's not returning a value. All the other object variables are fine except number, and match between my dev and live servers. Why just those two vars are missing, I don't know.

    You seem to be onto it with changing the $this->id to $this->id_base. That has a value of "widget_sp_image" on both. But that's specific to the widget, not the instance. Is that going to be a problem if you have multiple instances of the widget?

  25. capnhairdo
    Member
    Posted 4 years ago #

    And you're right that the PHP version makes a difference...turns out my live box is running PHP4 (dang it, MediaTemple, why do you default to that?). Could change it to 5, like my dev server, but prefer to finish troubleshooting this.

  26. capnhairdo
    Member
    Posted 4 years ago #

    I don't think replacing id with id_base will necessarily work. Correct me if I'm wrong here...

    image_send_to_editor() is a filter function hooked to 'image_send_to_editor'. That means it may get called several times, if anything else invokes that event. I've noticed that for me, it gets called once by the media uploader (media.php) when it tries to add a caption, and then again when it actually sends the image content back to the page.

    The filter function normally receives image HTML code and passes back the same. Your version replaces the image HTML with a JavaScript array. Thus, it should ONLY do this when you know for certain that you're passing data back to your image widget. In all other cases, it should return the image HTML. Otherwise, you'll get JavaScript where you don't want it.

    So I said that in my case, the filter function gets called multiple times, the first time when media.php tries to add a caption, and the second time when it sends the data back to the image widget. In both cases, the referer is the same and id_base is the same. So checking for id_base doesn't work; it matches both times, and you get a JavaScript containing a JavaScript array back, instead of a JavaScript array containing an image.

    Checking for id as you had it before was more correct. That ONLY happens on the second call, for some reason.

  27. Peter Chester
    Modern Tribe
    Posted 4 years ago #

    it should be fine. the id is managed in javascript. all that if statement does is determine if this is being used for a widget or a post. so using the generic image widget part for the id should work.

    Is it working for you?

  28. Peter Chester
    Modern Tribe
    Posted 4 years ago #

    i wish i could reliably pass an image widget id to the image_send_to_editor.

  29. capnhairdo
    Member
    Posted 4 years ago #

    I think I might have a better solution that doesn't involve changing the output of image_send_to_editor() at all. Can I get your email address so I can send?

  30. Peter Chester
    Modern Tribe
    Posted 4 years ago #

    peter at shaneandpeter.com

Topic Closed

This topic has been closed to new replies.

About this Topic