• I have been having trouble with the Add Media options when creating posts or pages. I tried everything in the sticky, but none of it helped, so I dove into the code.

    I was not having problems with the upload. My problem was with the “From URL” part of the form. Whatever I entered into it seemed to cause a blank screen to come up and nothing happened.

    In wp-admin/includes/media.php, there is a function called media_send_to_editor. It looks like this:

    function media_send_to_editor($html) {
            ?>
    <script type="text/javascript">
    <!--
    top.send_to_editor('<?php echo addslashes($html); ?>');
    top.tb_remove();
    -->
    </script>
            <?php
            exit;
    }

    I found that the addslashes function referenced was taking what a value for $html that looked like “<img src=’http://wordpress.org/img.jpg’>&#8221; and turning it into “<img src=”http://wordpress.org/img.jpg”>&#8221;. That was messing up the javascript.

    So, I changed it too look like this:

    function media_send_to_editor($html) {
            ?>
    <script type="text/javascript">
    <!--
    top.send_to_editor('<?php echo $html; ?>');
    top.tb_remove();
    -->
    </script>
            <?php
            exit;
    }

    Now it works fine.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘I Solved My Add Media Problem’ is closed to new replies.