Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mat Lipe

    (@mat-lipe)

    Hi Peekaa,
    This can be acheived using one of the built in filters liks so. Add the following to you theme’s functions.php file and adjust as necessary. This will affect all shortcodes so you might want to add an id to the ones you want to change like ‘id=images_only’ and change the first line to
    add_filter('simple_links_shortcode_output_images_only', 'sl_images_only', 1, 2);

    add_filter('simple_links_shortcode_output', 'sl_images_only', 1, 2);
    function sl_images_only($output, $object){
        foreach( $object as $link ){
            if( empty( $link->image) ) continue;
            $images_only .= sprintf('<a href="%s" target="%s" title="%s" %s>%s</a>',
                                        $link->meta['web_address'][0],
                                        $link->meta['target'][0],
                                        $link->meta['description'][0],
                                        empty( $link->meta['link_target_nofollow'] ) ? '': 'rel="nofollow"',
                                        $link->image
                                 );
        }
        return $images_only;
    }

    Hope this helps
    Cheers.

    Thread Starter peekaa

    (@peekaa)

    great, works, thanks a lot.

    Thread Starter peekaa

    (@peekaa)

    well, now I have found that the ordinary shortcodes stopped working. fe. this [simple-links category=”organizace” remove_line_break=”true” orderby=”title”] gives nothing, blank results. Can you help, fix?

    Plugin Author Mat Lipe

    (@mat-lipe)

    Are you using the

    'id=images_only'

    to target just the ones you want to affect?

    If so please change the first line of the code to
    add_filter('simple_links_shortcode_output_images_only', 'sl_images_only', 1, 2);

    like so

    add_filter('simple_links_shortcode_output_images_only', 'sl_images_only', 1, 2);
    function sl_images_only($output, $object){
        foreach( $object as $link ){
            if( empty( $link->image) ) continue;
            $images_only .= sprintf('<a href="%s" target="%s" title="%s" %s>%s</a>',
                                        $link->meta['web_address'][0],
                                        $link->meta['target'][0],
                                        $link->meta['description'][0],
                                        empty( $link->meta['link_target_nofollow'] ) ? '': 'rel="nofollow"',
                                        $link->image
                                 );
        }
        return $images_only;
    }

    And the shortcode for the ones you only want images should look like this

    [simple-links category="organizace" remove_line_break="true" orderby="title" id="images_only"]

    Hope this helps.

    Cheers

    Thread Starter peekaa

    (@peekaa)

    yes, seems to works. Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘mode "just images"’ is closed to new replies.