WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: Image Widget] Fix Image Widget in WordPress 3.0-RC1 (10 posts)

  1. kenvunz
    Member
    Posted 4 years ago #

    This patch will fix the problem where "Insert to Widget" button is disappeared when image is uploaded
    Add 'admin_init' action hook within the elseif block starts from line 44

    } elseif ( 'media-upload.php' == $pagenow || 'async-upload.php' == $pagenow ) {
            add_action( 'admin_init', array($this, "fix_async_upload_image") );
            ...
    }
    
    function fix_async_upload_image() {
    	if(isset($_REQUEST['attachment_id'])) {
    		$GLOBALS['post'] = get_post($_REQUEST['attachment_id']);
    	}
    }

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

  2. kenvunz
    Member
    Posted 4 years ago #

    Updated, better scoping

    if($this->is_sp_widget_context()) {
            add_action( 'admin_init', array($this, "fix_async_upload_image") );
            ...
    }
  3. chandlerwhite
    Member
    Posted 4 years ago #

    For a sort of novice - what file are you referring to?

  4. Will White
    Member
    Posted 4 years ago #

    The file is: image-widget/image-widget.php

    I'm having a hard time following though too. Any way you can explain this a little clearer? Thanks.

  5. Will White
    Member
    Posted 4 years ago #

    I just got it working.

    In image-widget.php line 44 replace

    } elseif ( 'media-upload.php' == $pagenow || 'async-upload.php' == $pagenow ) {
    				add_filter( 'image_send_to_editor', array( $this,'image_send_to_editor'), 1, 8 );
    				add_filter( 'gettext', array( $this, 'replace_text_in_thitckbox' ), 1, 3 );
    				add_filter( 'media_upload_tabs', array( $this, 'media_upload_tabs' ) );
    			}

    with

    }
    if ($this->is_sp_widget_context()) {
    		        add_action( 'admin_init', array($this, "fix_async_upload_image") );
    				add_filter( 'image_send_to_editor', array( $this,'image_send_to_editor'), 1, 8 );
    				add_filter( 'gettext', array( $this, 'replace_text_in_thitckbox' ), 1, 3 );
    				add_filter( 'media_upload_tabs', array( $this, 'media_upload_tabs' ) );
    			}

    Then add outside of all other functions:

    function fix_async_upload_image() {
    		if(isset($_REQUEST['attachment_id'])) {
    		$GLOBALS['post'] = get_post($_REQUEST['attachment_id']);
    		}
    	}

    It worked for me when I added it right after

    function loadPluginTextDomain() {
    		load_plugin_textdomain( $this->pluginDomain, false, trailingslashit(basename(dirname(__FILE__))) . 'lang/');
    	}

    Hope this helps.

  6. gvwriter
    Member
    Posted 4 years ago #

    @WillPCG
    Thanks.

    However, all I'm getting is the name of the file I'm trying to upload and the "alt text" with no image.

    http://www.articleandvideomarketing.com

    Suggestions?

  7. gvwriter
    Member
    Posted 4 years ago #

    Here is a simple workaround:
    NOTE:
    I AM NOT A CODE GUY... I'M SURE THERE ARE EASIER WAYS THAN THIS AND THIS IS NOT 100% GUARANTEED... IT JUST WORKED FOR ME!

    Upload your image to your library.
    Use at Text Widget.
    Then simply use href and src parameters.

    <a href="http://www.youtube.com/user/ArticleAndVideoMktng"><img src="http://www.articleandvideomarketing.com/images/youtube_62x62_whiteasseenon.jpg" border="0"></a>

    For example, if the URL you want to link to is:
    http://www.ThePageLocationOnTheInternet.com

    And your image is in your WordPress Library:
    http://www.MyWebSite.com/images/TheNameOfTheImageIWantToShowInMySidebar.jpg

    Then the html you would put in the Text Widget should look like this:

    <a href="http://www.ThePageLocationOnTheInternet.com
    "><img src="http://www.MyWebSite.com/images/TheNameOfTheImageIWantToShowInMySidebar.jpg
    " border="0"></a>

    That should do it.
    Good luck!

  8. Peter Chester
    Modern Tribe
    Posted 4 years ago #

    I've updated the plugin in 3.1.6 to fix wordpress 3.0 bugs. let me know if this solves it.

    Thanks!

    ~p

  9. sassymonkey
    Member
    Posted 4 years ago #

    I'm still having the no image problem on a local MAMP test install of WP 3.0 and 2.9.2 remotely.

    I tried the plugin unsuccessfully on my custom Thematic install (in both local WP 3 and remote WP 2.9.2 installs), a new blank Thematic install, and on a virgin Twenty Ten theme (both latter on local WP 3.0).

    This tells me it's not theme issue and is between the plugin and WP 2.9.2 and 3.0.

    Specifically, I can install the Image Widget plugin and then add it to my aside, but when I click the Add Image link, the pre-existing image in the Media Library I select does not show.

    The link text says "Change Image" but no thumbnail shows.

    If I click widget Save button, the link reverts to "Add Image" with no thumbnail showing.

    Regardless, no image is showing on the live site.

    I'm using most of the fields such as the Title, Caption, Link, Align: Left, Alt Text.

    I have also deactivated all plugins except Image Widget in local WP 3.0 to no avail (didn't try that in remote 2.9.2 install since it's a live public site).

    I notice also that I can't enter both the Height and the Width fields. If I enter a number into both, either one will be erased upon saving which seems confusing.

  10. sassymonkey
    Member
    Posted 4 years ago #

    Well, I'm stumped. I installed a completely fresh local MAMP version of WP 3.0 with a fresh download of Image Widget and it's working fine.

    Something in both of my other WP 3 and 2.9.2 are incompatible with Image Widget.
    ________

    Wondering though if the Image Widget is supposed to completely reset all of its fields when you change the image after successfully saving an instance.

    This seems excessive especially if all I want is to change the image and Caption text, leaving the Title, Link, sizes, and Alt Text as is.

Topic Closed

This topic has been closed to new replies.

About this Topic