majeedraza1 / carousel-slider

A WordPress plugin to Create SEO friendly Image, Logo, Video, Post, WooCommerce Product and HTML Content Carousel.
https://wordpress.org/plugins/carousel-slider/
Other
12 stars 3 forks source link

Feature : random order for images carousel #17

Closed Kendoulou closed 2 years ago

Kendoulou commented 3 years ago

Thanks a lot for all your work ! Most customizable carousel I found so far.

But I think a feature is missing : shuffle images order.

I did it for my website by modifying your plugin. In template\public\images-carousel.php I added shuffle($images_ids); just before your foreach ( $images_ids as $image_id ):

I think it will be cool to enable it as a parameter of your carousel.

Thanks again for your work

Kendoulou commented 3 years ago

Ok, so I might have found a solution that fits me really well. Here are the changes I made :

In images-settings.php I added this checkbox :

            $this->form->checkbox( array(
                'id'    => '_shuffle_images',
                'name'  => esc_html__( 'Shuffle', 'carousel-slider' ),
                'label' => esc_html__( 'Shuffle Images Order', 'carousel-slider' ),
                'desc'  => esc_html__( 'Check to shuffle images order at each page refresh.', 'carousel-slider' ),
                'std'   => 'off'
            ) );

In images-carousel.php : After : $_lazy_load_image = get_post_meta( $id, '_lazy_load_image', true ); I added $_shuffle_images = get_post_meta( $id, '_shuffle_images', true );

And after <div <?php echo join( " ", $this->carousel_options( $id ) ); ?>> <?php

I added the lines :

        if ( $_shuffle_images == 'on' ) {
            shuffle($images_ids);
        }

Please add this feature in your next update !