WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Images not Saving to Image Widget

[Resolved] Images not Saving to Image Widget

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

Viewing 15 replies - 16 through 30 (of 63 total)
  • 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?

    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.

    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.

    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.

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

    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.

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

    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?

    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.

    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.

    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?

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

    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?

    peter at shaneandpeter.com

    peter at shaneandpeter.com

Viewing 15 replies - 16 through 30 (of 63 total)
  • The topic ‘[Resolved] Images not Saving to Image Widget’ is closed to new replies.