admin管理员组

文章数量:1323006

I'm working on a Wordpress site, where all images inside posts are linking to the corresponding attachment pages. I want to use a lightbox but obviously this would require changing all the links back to the media files directly (e.g. xyz.jpg).

The site has a significant number of posts and images so it would be impossible to do this manually.

Does anyone know of solution that would simply replace - in bulk - all of the image links to link to the media file, instead of the attachment page?

I'm working on a Wordpress site, where all images inside posts are linking to the corresponding attachment pages. I want to use a lightbox but obviously this would require changing all the links back to the media files directly (e.g. xyz.jpg).

The site has a significant number of posts and images so it would be impossible to do this manually.

Does anyone know of solution that would simply replace - in bulk - all of the image links to link to the media file, instead of the attachment page?

Share Improve this question edited Apr 17, 2014 at 15:30 Pim asked Apr 17, 2014 at 13:54 PimPim 1,1521 gold badge11 silver badges26 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 2

I found a nice snippet at this site for your functions.php that does the trick:

 add_shortcode( 'gallery', 'file_gallery_shortcode' ); 

 function file_gallery_shortcode( $atts ) {
      $atts['link'] = 'file';
      return gallery_shortcode( $atts );
 }

I'd actually been looking unsuccessfully for the same thing, so I'm glad you asked.

本文标签: Replacing all attachment links in post with media file link