Forums

Media Gallery Shortcode Not Working (10 posts)

  1. rhayashida
    Member
    Posted 3 years ago #

    I upgraded to WP 2.7 last week and just noticed today that my [gallery] shortcode is not working on any of previous posts or new posts. All that displays is the description of each image, and no image. I'm alos using lightbox2 plugin, which I did disable and the gallery shortcode still doesn't work on new posts. I can insert individual images and display them without any problems. Any help would be much appreciated.

    To see what I'm talking about visit http://www.sandbox8.com

    Thanks
    Rob

  2. cipote
    Member
    Posted 3 years ago #

    I'm having problems with the built in gallery as well. I have deactivated all plugins to no avail.
    Before 2.7 I was not even able to insert the gallery into posts because the galler tab would be blank. Now I get all the option except that it does not display.

  3. rhayashida
    Member
    Posted 3 years ago #

    I have a solution to this problem;

    in wp-includes/post-template.php replace the existing code for

    Retrieve an attachment page link using an image or icon, if possible.
     *
     * @since 2.5.0

    with this new code below:

    /**
     * Retrieve an attachment page link using an image or icon, if possible.
     *
     * @since 2.5.0
     * @uses apply_filters() Calls 'wp_get_attachment_link' filter on HTML content with same parameters as function.
     *
     * @param int $id Optional. Post ID.
     * @param string $size Optional. Image size.
     * @param bool $permalink Optional, default is false. Whether to add permalink to image.
     * @param bool $icon Optional, default is false. Whether to include icon.
     * @return string HTML content.
     */
    function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false, $icon = false) {
    	$id = intval($id);
    	$_post = & get_post( $id );
    
    	if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
    		return __('Missing Attachment');
    
    	if ( $permalink )
    		$url = get_attachment_link($_post->ID);
    
    	$post_title = attribute_escape($_post->post_title);
    
    	$link_text = wp_get_attachment_image($id, $size, $icon);
    
    	//modification introduced to force the gallery shortcode thumbnail hyperlink to the full size image directly, rather than the attachment page
    		$url = wp_get_attachment_url($_post->ID);
    
    	if ( !$link_text )
    		$link_text = $_post->post_title;
    
    	return apply_filters( 'wp_get_attachment_link',"<a href="$url" title='$post_title'>$link_text</a>", $id, $size, $permalink, $icon );
    }

    This corrected the gallery shortcode problem. Backup your original post-template.php before replacing this block of code.

    Thanks to Mark Pedereson for the help on this.
    R

  4. cipote
    Member
    Posted 3 years ago #

    I tried this and my blog just shows a blank page.

  5. rhayashida
    Member
    Posted 3 years ago #

    If this page is blank, than there is a typo.

    function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false, $icon = false) {
    	$id = intval($id);
    	$_post = & get_post( $id );
    
    	if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
    		return __('Missing Attachment');
    
    	if ( $permalink )
    		$url = get_attachment_link($_post->ID);
    
    	$post_title = attribute_escape($_post->post_title);
    
    	$link_text = wp_get_attachment_image($id, $size, $icon);
    
    	//modification introduced to force the gallery shortcode thumbnail hyperlink to the full size image directly, rather than the attachment page
    		$url = wp_get_attachment_url($_post->ID);
    
    	if ( !$link_text )
    		$link_text = $_post->post_title;
    
    	return apply_filters( 'wp_get_attachment_link',"<a href=$url title='$post_title'>$link_text</a>", $id, $size, $permalink, $icon );
    }

    I accidently pasted old version of the code. This is the updated version that corrected the problem.

    R

  6. cipote
    Member
    Posted 3 years ago #

    @rhayashida,
    Thank you so much for trying to help with this. I made the change and now I don't get the blank page. I get the normal look and field of the posts except that the 'gallery' is still not working.
    I've even deactivated all my plugins...

  7. cipote
    Member
    Posted 3 years ago #

    Okay, after trying many different things with my current blog and not having any luck I decided to create a new blog for testing.
    I think I have found that the culprit here is my webhosting services (Yahoo Small Business). I even created this blog under a different account...

    I created a new blog and I updated it to 2.7, disabled all plugins and still no luck! I will try to contact tech support with this new info and see where it gets me!

  8. omgitztrey
    Member
    Posted 2 years ago #

    Any fixes?

  9. Masselyn
    Member
    Posted 2 years ago #

    Interesting, because I have the same problem - Gallery not working at all no matter what short code I use - and I am also on Yahoo! hosting. What the heck are they doing that would stop this small thing from working? I am going to try the same blog on my GoDaddy account and see if I have more success. This sucks!

    :(

  10. Masselyn
    Member
    Posted 2 years ago #

    Low and behold the same exact plugin works fine on my GoDaddy account, but gives me nothing when installed on a blog that resides on Yahoo! Kinda weird, if you ask me, but I have found numerous anomalies like this while working between the two hosting companies - where certain things function on one and not on the other.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.