WordPress.org

Ready to get started?Download WordPress

Forums

"Linked to Image" by default (5 posts)

  1. friend_of_grommit
    Member
    Posted 8 years ago #

    I need help.

    I'd like the upload functionality in WP 2.0 to select "Linked to image" by default.

    Right now "Not Linked" is the default.

    So I did some hacking...

    in inline-uploading.php, line 249

    I changed

    __not_linked
    to
    __linked_to_image

    and I made all kinds of different combo changes to the toggleLink function. (lines 335-344)

    Currently, they look like:

    if ( ol.innerHTML == notlinked ) {
    od.innerHTML = ab[n]+img+'</a>';
    ol.innerHTML = linkedtoimage;
    } else if ( ol.innerHTML == linkedtoimage ) {
    od.innerHTML = img;
    ol.innerHTML = notlinked;
    }
    else {
    od.innerHTML = ab[n]+img+'</a>';
    ol.innerHTML = linkedtoimage;
    }

    So here's what's happening...

    you upload a photo, you click on it, it SAYS "Linked to image" but if you send to editor, it is NOT linked.

    click on it again, it says "Not Linked" and indeed it is not linked.

    Here's where it gets strange. Click a third time and it SAYS "Linked to image" and this time is REALLY IS linked to image! Then every click works properly after that.

    So it's the first click that's messed up.

    Anyone know how to get "Linked to Image" the default choice and have it actually work?

    Thanks!

  2. zarastudios
    Member
    Posted 8 years ago #

    Has anyone figured this one out? I'm interested in getting this to work, too. Thanks.

  3. 3stripe
    Member
    Posted 8 years ago #

    Sounds good to me too... I think image uploading/thumbnailing/sizing should all be more controllable somehow, could be a nice plugin?

  4. pkscout
    Member
    Posted 7 years ago #

    OK, it took me awhile to figure this out, but it all has to do with how the DOM object is constructed by default. Once I got that, it's actually just two places you have to make two changes. I'm going to provide line numbers, but the line numbers I have don't seem to match up with the ones above (maybe because I have a slightly newer version of WordPress), so I'll also try and describe where they are.

    On line 427 you'll see:

    function sendToEditor(n)

    Right under that add:

    updateImage(n);

    On line 256 you need to find:

    <a id=\"L{$ID}\" onclick=\"toggleLink({$ID});return false;\" href=\"javascript:void()\">$__not_linked</a>

    Where you see $__not_linked change that to $__linked_to_image.

    That's it. Now when you click on the thumbnail in the image browser it will default to Link to Image and it will actually go to the browser that way.

    Why does this work? Well updateImage() looks at the div element for a given picture's popup and figures out what text is there (i.e. Not Linked, Linked to Image, etc). Then based on that, it changes some of the DOM information for that DIV to add the other stuff that creates that link. So by adding that to SendtoEditor, you can change the default text and that allows the DOM to be updated. Without that, the DOM is only updated if you click on the option. That's why you were seeing the behavior you did regarding it only working if you clicked the option you wanted to change at least once.

  5. jandry
    Member
    Posted 7 years ago #

    I just wanted to suggest to add something in the option to change the inline uploader default option in a future version.
    It's very useful.

Topic Closed

This topic has been closed to new replies.

About this Topic