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

    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 ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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

    spiretop

    (@spiretop)

    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!

    Thread Starter loic.etibe

    (@loicetibe)

    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 ^^

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Plugin broke my posts' image gallery’ is closed to new replies.