• Hello –
    We are trying to make one of our images easily downloadable, but I can’t seem to figure it out. I have created a link to the .jpg file and no matter what I try, the link opens the image in a lightbox effect. Ideally, for this one image, I’d like to figure out one of two options:
    a) When someone clicks the link, they are prompted to save the .jpg file
    or
    b) When someone clicks the link, a new window/tab opens solely with the .jpg file open.

    I’ve tried a adding target="_blank" and rel="NON" and a few other attributes, all with no success. Can someone help me out?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Disable lightbox effect unchecking this:
    Appearance -> Customize -> Images -> Enable/disable lightbox effect on images

    Thread Starter btonetbone

    (@btonetbone)

    I’m trying to disable it for only this one image; we want it to work on the rest.

    Thanks!

    Basically when you have that option enabled the class “grouped_elements” is added to each a href which wraps each image, and then processed by fancybox javascript..
    So in my opinion, probably the only way to achieve that is with js.

    EDIT:
    maybe there’s a simple solution with one of nikeo’s magical filters ??
    wait .. I’ll be back

    Ok something working:

    add_filter('tc_fancybox_content_filter', 'my_fancybox_content_filter');
    function my_fancybox_content_filter( $content ){
        /* you can do some check here to return quickly if you're not in the right place, for example*/
        $page_slug = 'lorem'; /* the slug of your page */
        if ( ! is_page( $page_slug ) )
            return $content;
    
        $linked_image = "something.png"; /* just the filename */
        $rel = 'NON';
        $class = 'no_fancybox'; /*don't leave this blank*/
    
        $pattern ="/<a(.*?)href=( '|\")(.*?)(".$linked_image.")( '|\")(.*?)>/i";
        $replacement = '<a$1href=$2$3$4$5 rel="'.$rel.'" class="'.$class.'" $6>';
        $content = preg_replace( $pattern, $replacement, $content);
    
        return $content;
    }

    Of ‘course if you’re good with regexp you can find a better way. The relevant part is the filter you have to use, tc_fancybox_content_filter (customizr/inc/class-fire-utils.php)

    Hope this helps

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Make an image easily downloadable’ is closed to new replies.