WordPress.org

Forums

I Solved My Add Media Problem (3 posts)

  1. rexgoode
    Member
    Posted 6 years ago #

    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'>" and turning it into "<img src=''http://wordpress.org/img.jpg''>". 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.

  2. MichaelH
    Member
    Posted 6 years ago #

    I'll note this thread on trac ticket 6414

  3. MichaelH
    Member
    Posted 6 years ago #

    Ah, the answer is really trac ticket 6898.

Topic Closed

This topic has been closed to new replies.

About this Topic