0

I am having two related problems:

In the Media Library, when I click on edit image, I don't see the image load on the left part that allows to crop etc. Similarly, I can't edit nggallery thumbnails, the image with cropper aren't loaded.

This bug only occurs when using my theme. It works well when I switch back to say Twenty Eleven.

However, I have no idea what could be causing this from my theme.

Any suggestion?

enter image description here

EDIT: I followed toscho's comment, I noticed that the following pieces of code are causing the problem described here. One of those functions is enough to cause the issue.

1) This code to include jquery from cdn

<?php
  /************* INCLUDE JQUERY 1.10.0 FROM CDN *****************/
if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
function my_jquery_enqueue() {
   wp_deregister_script('jquery');
   wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://code.jquery.com/jquery-latest.min.js", false, null);
   wp_enqueue_script('jquery');
}
?>

The following functions that I coded myself...

    <?php
    /*
     * this is a helper function to get wordpress metadata
     * for an attachment (wordpress media file)
     * 
     */
    function custom_wp_get_attachment( $attachment_id ) {

        $attachment = get_post( $attachment_id );

        $path_parts = pathinfo($attachment->guid);

        return array(
            'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
            'caption' => $attachment->post_excerpt,
            'description' => $attachment->post_content,
            'href' => get_permalink( $attachment->ID ),
            'dirname' => $path_parts['dirname'],
            'basename' => $path_parts['basename'],
            'extension' => $path_parts['extension'],
            'filename' => $path_parts['filename'],
            'title' => $attachment->post_title
        );
    }
    ?>

.

    <?php
    /************* REPLACE TAGS TO EMBED YOUKU VIDEOS *****************/
    // [youku vid="video id" width="width" height="height"]
    function youku_func( $atts ) {
        $atts =  shortcode_atts( array(
            'vid' => '',
        ), $atts );

        return "<iframe src='http://player.youku.com/embed/" . $atts['vid'] . "'></iframe>";
    }
    add_shortcode( 'youku', 'youku_func' );

    ?>

.

    <?php
    /************* REPLACE TAGS TO EMBED LOCAL VIDEOS *****************/
    // [local video=""VideoName width="width" height="height"]
    function localvideo_func( $atts ) {

        $atts =  shortcode_atts( array(
                'name' => '',
                'width' => "400",
                'height' => "200",
             ), $atts );

        $contentUrl = content_url();

        return "<video width='" . $atts['width'] ."' height='" . $atts['height'] . "' controls>
                             <source src='$contentUrl/wp-content/uploads/" . $atts['name'] . ".mp4' type='video/mp4' />
                             <source src='$contentUrl/uploads/" . $atts['name'] . ".ogg' />
                             <object width='" . $atts['width'] . "' height='" . $atts['height'] . "' type='application/x-shockwave-flash' data='http://localhost/dangsters/wp-content/uploads/" . $atts['name'] . ".swf'>
                                    <param name='movie' value='$contentUrl/uploads/" . $atts['name'] . "'.swf' />
                                    <param name='flashvars' value='controlbar=over&amp;image=http://localhost/dangsters/wp-content/uploads/" . $atts['name'] . ".jpg&amp;file=http://localhost/dangsters/wp-content/uploads/" . $atts['name'] . "'.mp4' />
                                    <img src='$contentUrl/uploads/" . $atts['name'] . ".jpg' width='" . $atts['width'] ."' height='" . $atts['height'] . "' alt='" . $atts['name'] . "'
                                        title='No video playback capabilities, please download the video below' />
                                </object>
                        </video>
                        <p> <strong>Download Video:</strong>
                            Closed Format:  <a href='$contentUrl/uploads/" . $atts['name'] . ".mp4'>MP4</a>
                            Open Format:    <a href='$contentUrl/uploads/" . $atts['name'] . ".ogg'>OGG</a>
                        </p>";


    }
    add_shortcode( 'localvideo', 'localvideo_func' );

    ?>

What's the matter with those functions?

  • 2
    Remove all back-end related code from your theme. Does it still happen? If so, add that code to your question. – fuxia Jul 14 '13 at 10:46
0

This bug was caused by empty lines between php tags...

<?php function(){ ... } ?>

<?php function(){ ... } ?>

needs to be:

<?php function(){ ... } ?>
<?php function(){ ... } ?>

wordpress.org

Credit: wordpress.org

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.