Problem/Motivation

When a slide show only has 1 image, you see this in the console:

Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled and not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters

Steps to reproduce

Create a slideshow with only 1 image

Proposed resolution

Check for number of slides before sending to JS.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jcl324 created an issue. See original summary.

kul.pratap’s picture

Assigned: Unassigned » kul.pratap

kul.pratap’s picture

Assigned: kul.pratap » Unassigned
Status: Active » Needs review
StatusFileSize
new93.09 KB

I have generated MR, Kindly check it.
No Warning after that.
Fixed_issue_error

kul.pratap’s picture

Please check it (:

nk_’s picture

Version: 2.0.1-beta4 » 2.0.x-dev
Assigned: Unassigned » nk_

Thanks. I thought it was safer to do make this logic in PHP, so I placed a few lines of code in the module to not even initialize swiper but do inform (status warning) user about it.
Note that this is only in 1.0.x-dev version for now. For 2.0.x will come soonest

nk_’s picture

Status: Needs review » Active

nk_’s picture

Assigned: nk_ » bbu23
Status: Active » Needs review

Pushed into 2.0.x-dev and is ready for testing.

tirupati_singh’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new321.94 KB

Hi @nk, I've tested the mentioned issue on 2.0.x-dev and when the number of slide is less than 2 getting a warning message as shown in the attached screenshot when saving/updating the node. And confirm that the changes are working fine, did not get any console errors when the slider has only one slide. I'm attaching the screenshot for your reference. As the changes are working fine moving the issue to RTBC.

Thanks!

bbu23’s picture

Status: Reviewed & tested by the community » Fixed

Thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

bbu23’s picture

Assigned: bbu23 » Unassigned
dalin’s picture

Oooph.

This patch causes many problems:
* PHP warning because of sometimes `count()` on NULL.
* Despite the permissions check, this patch doesn't set cache contexts, so the warning message will be cached and shown to anonymous visitors.
* I'm unsure why a content editor needs to be told that a widget is choosing option B instead of option A. This is just confusion inducing.
* IMO the JS console message is a _good_ thing to help debug what's going on. IMO there's no need to remove it in the first place, though I understand why others might disagree.

I'll roll a new issue to fix the first three.