WordPress.org

Support

Support » Plugins and Hacks » Update image links from "link" to "file"

Update image links from "link" to "file"

  • Franz92

    @franz92

    Hello!
    I want to update all image links in articles. Currently they are linked to their attachment pages, I want to link them directly to the file to use a lightbox-style plugin.

    I found this code. It sets image links to “none” – that is nearly what I want, I want them to be set to “file” – is that possible?

    This is the “remove”-code:

    add_filter( 'the_content', 'attachment_image_link_remove_filter' );
    function attachment_image_link_remove_filter( $content ) {
     $content =
     preg_replace(
     array('{<a(.*?)(wp-att|wp-content/uploads)[^>]*><img}',
     '{ wp-image-[0-9]*" /></a>}'),
     array('<img','" />'),
     $content
     );
     return $content;
     }

    Thank you very much for your answer!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Jan Dembowski

    @jdembowski

    Brute Squad and Volunteer Moderator

    I want to link them directly to the file to use a lightbox-style plugin.

    Which plugin? Usually the plugin will take care of the displaying of the image in a lightbox without having do play with filters like that.

    Franz92

    @franz92

    Hey!
    Thanks for your reply. It is “FancyBox for WordPress”, running on aktuelles-bodensee.de

    Did that help?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Update image links from "link" to "file"’ is closed to new replies.
Skip to toolbar