• Resolved tjdyo

    (@tjdyo)


    Is it possible to get an option to load an image randomly with the Image Carousel?

    I am using the image carousel to display a square image in a widget spot that slides between images.

    I need this function to be random, as we are using this spot to load “albums of the week” and it needs to display a different album first on each load of a page.

    I’d be happy to donate to receive this added feature!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Vova

    (@gn_themes)

    Hi @tjdyo,

    this will be possible after the closest update, in a week or less.

    You’ll need to do add a custom CSS class to your shortcode and add the following snippet to the functions.php file:

    add_filter(
    	'su/get_gallery_slides_query',
    	function( $query, $source, $atts ) {
    
    		if ( ! isset( $atts['class'] ) || strpos( $atts['class'], 'random-image' ) === false ) {
    			return $query;
    		}
    
    		$query['ignore_sticky_posts'] = true;
    		$query['orderby']             = 'rand';
    
    		return $query;
    
    	},
    	10,
    	3
    );
    

    And this is the example of what CSS class you should add:

    [su_image_carousel class="random-image"]
    

    You can donate by purchasing any of the premium add-ons here.

    Thread Starter tjdyo

    (@tjdyo)

    For some reason this didn’t work for me. Can’t wait for the update, and I definitely will buy a premium addon. Thank you for the great support!

    Thread Starter tjdyo

    (@tjdyo)

    Any chance that update is coming soon? The last update didn’t include the feature to randomly load the images I choose.

    I need to be able to pick 2-10 images and have it randomly start with one per page load. I added the code to my functions.php and added the class to my shortcode, but nothing changed.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Image Carousel – Load Random Image?’ is closed to new replies.