Support » Fixing WordPress » JS error in WP 3.5 gallery re-order tool

  • Resolved DrSynonym

    (@drsynonym)


    i can re-order galleries but the changes are not reflected on the site.

    Uncaught TypeError: Cannot call method ‘get’ of null media-views.js:525

    How can this be resolved?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Try first deactivating all of your plugins… then manually empty your browser cache… then repeat the process and see if you still get the error.

    If you don’t (which you shouldn’t), repeat the process as you re-activate your plugins one at a time… until it “breaks” again. Then, you know which plugin is incompatible.

    Thanks.

    I’ve done that – nothing changes. I’m only running two plugins but the code of the theme is heavily customized.

    I’m using Chrome Canary and have also tried using Firefox. What’s odd is that gallery re-ordering did work earlier in the day and, when I had my first problem, re-uploading the content seemed to fix it.

    When I change ‘order’ in the following code the display order changes on some of the galleries on the page but not others. When I look at the galleries in the editor the order of images is correct. It’s just not correct on the page.

    This is the code I’m using to display galleries with custom formatting:

    if (have_posts()) : while (have_posts()) : the_post(); 
    
    	$posttags = get_the_tags();
    	$count=0;
    	$tagged = '';
    
    	if ($posttags) {
    		foreach($posttags as $tag) {
    			if (0 == $count) {
    				$tagged = $tag->name;
    				$count++;
    				}
    			}
    		}
    
    	if($tagged == 'exhibition') { ?>
    
    		<?php
    			$attachments = get_posts(array
    				(
    				'post_type' => 'attachment',
    				'numberposts' => -1,
    				'post_status' => 'published',
    				'post_parent' => $post->ID,
    				'orderby' => 'menu_order',
    				'order' => 'ASC'
    				)
    			);
    
    		if ( $attachments ) {
    			foreach ( $attachments as $attachment ) {
    				$attachment_page = get_attachment_link( $attachment->ID ); 
    
    					echo '<div class="post-preview"><div class="gallery-icon"><a href="';
    					echo wp_get_attachment_url( $attachment->ID );
    					echo '">';
    					$myimage = preg_replace( '/(width|height)=\"\d*\"\s/', "", wp_get_attachment_image($attachment->ID, thumbnail) ); echo $myimage;
    					echo '</a></div></div>';
    				}
    			}

    I’ve found that changing

    'orderby' => 'menu_order'

    to

    'orderby' => 'post__in'

    fixes the problem on most posts but not all. Strange…

    I’m really upset.

    The media uploader isn’t working at all. Sometimes it records changes, other times not. I don’t think it’s my code – it was working great before.

    For the first time ever I’m downgrading to an older version. This site is in production. I cannot afford for this not to work as it should.

    Any help much appreciated.

    I have the same issue. the 3.5 Gallery editor is not working right. I even checked the gallery code and it reorders the IDs but doesn’t do so on the front end. Right now the Images are in the right order in the back end, but on the front end they are reversed, and clicking the reverse order doesn’t solve the issue and manually dragging and dropping does not either.

    esmi

    (@esmi)

    Forum Moderator

    As per the Forum Welcome, please post your own topic. Posting in an existing topic prevents us from being able to track issues by topic. Added to which, your problem – despite any similarity in symptoms – is likely to be completely different.

    DrSynonym, did you ever find a solution to this, or did you just downgrade? I’m having an issue that seems very similar. I too changed orderby from menu_order to post__in to no avail.

    I did get an answer.

    “I figured it out: If you use a gallery with images, which are already uploaded to the media library, the gallery shortcode looks like [gallery ids=1,2,3], what means, that images are only linked (and not attached) to the gallery, so post_type=attachment doesn’t work.

    Now i’m using regular expressions to get the image IDs:”

    <?php
    $the_cat = get_the_category();
    $category_name = $the_cat[0]->cat_name;
    $category_description = $the_cat[0]->category_description;
    $category_link = get_category_link( $the_cat[0]->cat_ID );
    $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
    
    echo '<div class="titleblock-2"><p>';
    echo customTitle(50);
    echo '</p></div>';
    
    $attachments = get_posts(array
        (
        'post_type' => 'attachment',
        'numberposts' => -1,
        'post_status' => 'published',
        'post_parent' => $post->ID,
        'orderby' => 'menu_order',
        'order' => ''
        )
    );
    
    if ( $attachments ) {
        echo '<div id="singlegallery">';
        foreach ( $attachments as $attachment ) {
            $attachment_page = get_attachment_link( $attachment->ID );
            echo '<div class="big-thumb"><div class="gallery-icon"><a href="';
            echo wp_get_attachment_url( $attachment->ID );
            echo '">';
    
            $myimage = preg_replace( '/(width|height)=\"\d*\"\s/', "", wp_get_attachment_image($attachment->ID, medium) ); echo $myimage; 
    
            echo '</a></div></div>';
            }
        echo '</div>';
    } else {
        $post_content = $post->post_content;
        preg_match('/\[gallery.*ids=.(.*).\]/', $post_content, $ids);
        $attachment_ids = explode(",", $ids[1]);
        foreach ($attachment_ids as $attachment_id) {
    
            // here you can use your old code for printing images, but use "$attachment_id" instead of "$attachment->ID"
        }
    } 
    
    ?>

    You can read more here.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘JS error in WP 3.5 gallery re-order tool’ is closed to new replies.