• Resolved Ivo

    (@ivobirrer)


    Hi Philipp

    I am wondering whether it is possible to

    1.) make Slick Slider default instead of checking it every time
    2.) default another Media Size instead of thumbnails (e.g. I have added a Size “Article-Slider” which I would like to default in case Slick Slider is chosen)
    3.) default the “Link to” to “Media” instead of Attachment or any other.

    It would be great a) if this is possible and b) if it could be added to the Settings to be set up.

    Thank you for taking this into consideration.

    Brgds
    Ivo

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter Ivo

    (@ivobirrer)

    Hi Philipp

    I was able to partially fix the above by making use of the Function my_gallery_default_type_set_link (regarding the Link to). For the Default Size I have found a solution on stackoverflow .

    So the only thing that I was not able to fix is that Slick Slicker is tick marked by default.

    Brgds
    Ivo

    Plugin Author Philipp Bammes

    (@tyrannous)

    Hi @ivobirrer,
    I’m really sorry for the delay; have been very busy in the past weeks.

    I’m glad you were able to solve some of the issues on your own. For the sake of completeness I’d like to post “my” suggestion how to solve this.

    Use the filter shortcode_atts_gallery (see the FAQ’s, question “Is it possible to change the gallery attributes using PHP?”):

    
    /**
     * 1. Link images to media file.
     * 2. Set the image size to <code>large</code>.
     * 3. Always use Slick Slider.
     */
    add_filter( 'shortcode_atts_gallery', function( $result, $defaults, $atts ) {
    	$result['link'] = 'file'; // 1.
    	$result['size'] = 'large'; // 2.
    	$result['slick_active'] = true; // 3.
    	return $result;
    }, 10, 3 );
    

    Note: Substitute image size large with your custom image size.

    The main difference to the media_view_settings hook is that shortcode_atts_gallery is only executed for galleries and not for all media files.

    Important note: The current version of Slick Slider (0.5.1) does not respect slick_active set with the shortcode_atts_gallery filter. I made a change on the development version to add support for this. You need to manually install it to make it work.

    The next version will probably have a setting on the Media Settings page to always enable Slick Slider.

    I hope this is useful for you.

    Thread Starter Ivo

    (@ivobirrer)

    Hi Philipp

    No issue. Glad that you found time to answer my Questions. I have tried the above solution but Slick-Slider stops running as soon as I add the above filter. It simply shows the native gallery again.

    Brgds
    Ivo

    Plugin Author Philipp Bammes

    (@tyrannous)

    Ah, my bad.

    I was testing the code against the unpublished in-development version of this plugin. $result['slick_active'] = true; (boolean) will only work from the next version on. For now, you’ll have to write $result['slick_active'] = 'true'; (string).

    Sorry for this!

    Note that on the gallery modal the checkbox “Use Slick Slider” will have no effect and will stay unchecked. Don’t get confused by this.

    Thread Starter Ivo

    (@ivobirrer)

    Runs like a charm. Many thanks for your outstanding support!

    Tried to switch-off Slick-Slider for one of my Galleries by adding slick_active=”false” to the Shortcode. Same I tried for the “Link to” because I use Slick-Slider also in the Widgets and there images should not be linked to anywhere. But now it seems that any tweaking to the Shortcode is ignored, right?

    BTW: Another Donation is on its way to you.

    Plugin Author Philipp Bammes

    (@tyrannous)

    That’s a legitimate objection.
    Let’s check if the attributes are set in the shortcode (meaning they differ from the WordPress defaults, see below) and if so, don’t overwrite them:

    
    /**
     * 1. Link images to media file.
     * 2. Set the image size to <code>large</code>.
     * 3. Always use Slick Slider.
     */
    add_filter( 'shortcode_atts_gallery', function( $result, $defaults, $atts ) {
    	if ( ! isset( $result['link'] ) ) {
    		$result['link'] = 'file'; // 1.
    	}
    	if ( ! isset( $result['size'] ) ) {
    		$result['size'] = 'large'; // 2.
    	}
    	if ( ! isset( $result['slick_active'] ) ) {
    		$result['slick_active'] = 'true'; // 3.
    	}
    	return $result;
    }, 10, 3 );
    

    The default value for link is “Attachment Page”, for size is thumbnail. See Gallery Shortcode for details.

    I hope we get closer to a useful solution.

    Thanks for your donation!

    Thread Starter Ivo

    (@ivobirrer)

    Philipp, great job!

    Exactly what I was looking for. Many thanks for your very appreciated support and this great plugin.

    Would be great if you could implement this into the Settings Page. This came up because my fellow colleagues often forget to maintain the right settings (e.g. Slick Slider = on, Link to = File and preferred Image-Size).

    Plugin Author Philipp Bammes

    (@tyrannous)

    I’m glad it’s working for you. Set to resolved.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Slick Slider Default, Size and Image Link’ is closed to new replies.