WordPress.org

Support

Support » How-To and Troubleshooting » On gallery, no link on FILE

On gallery, no link on FILE

  • Hello,

    I use the new Gallery System on worpress with a size that need to be always the same. Already ahve it and everything its working good.

    The only problem is that I DON’T need the links to the image URL on each image gallery. Just want to insert the [gallery.. ] and have NO images links.

    I find the code that set the link on each image.. but don’t know what to remove.

    <!-- see gallery_shortcode() in wp-includes/media.php -->
    <div class='gallery'>");
    $i = 0;
    foreach ( $attachments as $id => $attachment ) {
    
    $link = isset($attr['link']) &amp;&amp; 'file' == $attr['link'] ? 
    
    wp_get_attachment_link($id, $size, false) : wp_get_attachment_link($id, $size, false);
    
    $output .= "
    <br style='clear: both;' />
    </div>\n";
    
    return $output;
    }

    Thanks,

Viewing 4 replies - 1 through 4 (of 4 total)
  • JosVelasco

    @josvelasco

    Any ideas on this?

    I’d like to have something like [gallery link="none"] instead of [gallery link="attachment"] or [gallery link="file"]

    I did this using jQuery to remove the link for the user. For the spiders, I set it to link=”file” so that the spiders don’t crawl to a useless page.

    I don’t like modifying the core files since it’ll break again every time you upgrade your WP installation. Hope this helps.

    $(document).ready(function(){
    	// Remove link from gallery images
    	$(".gallery-icon a").each(function () {
    		$(this).replaceWith($(this.childNodes));
    	});
    });

    @jayde
    Thanks for your response. Where did you place this code?

    @jayde

    Very interested in the answer to the above question. I’m struggling to figure out how to get the links removed from these images.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘On gallery, no link on FILE’ is closed to new replies.
Skip to toolbar