Forums

Link Image Gallery
Plugin broke my posts' image gallery (4 posts)

  1. loic.etibe
    Member
    Posted 10 months ago #

    The Link section was working fine with this nice plugin, but broke everything else related to media upload :P

    As a workaround, I hacked into the code and changed the media_send_to_custom_field() function, which was now pointing to the wrong JS function.

    Here is my version (link-image-gallery.php) :

    function media_send_to_custom_field($html) {

    preg_match('/src="([^"]+)"/', $html, $matches);
    $html_custom = $matches[1];
    $html_custom = str_replace(site_url(), '', $html_custom);
    ?>
    <script type="text/javascript">
    var iframeParent = window.parent.location.toString();
    var matches = iframeParent.match(/link.php/);
    var win = window.dialogArguments || opener || parent || top;
    if (matches) win.send_to_custom_field("<?php echo trim(addslashes($html_custom)) ?>");
    else win.send_to_editor('<?php echo addslashes($html); ?>');
    win.tb_remove();
    </script>
    <?php
    exit();

    }

    Hope this can help someone :-)

  2. dwcouch
    Member
    Posted 9 months ago #

    Thank YOU! And here's an update/variant to the function media_send_to_custom_field

    I had to change var matches = iframeParent.match(/link.php/);
    to var matches = iframeParent.match(/link-add.php/);

    ~ WP Version WordPress 3.1

  3. spiretop
    Member
    Posted 3 months ago #

    This is great! Thanks for fixing this.

    However, it seems the first set of code works when EDITING a link, and the second set works when ADDING a link.

    Can one of you figure out how to make it work on both pages (link.php and link-add.php)?

    Thanks!

  4. loic.etibe
    Member
    Posted 3 months ago #

    Maybe you just have to change the regexp to allow both ?

    Like :

    var matches = iframeParent.match(/[link\.php|link\-add\.php]/);

    I'm not sure about the regexp, but it's something like that ^^

Reply

You must log in to post.

About this Plugin

About this Topic