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.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | Screenshot from 2024-11-25 14-40-43.png | 321.94 KB | tirupati_singh |
| #4 | Js Warning error.png | 93.09 KB | kul.pratap |
Issue fork swiper_formatter-3479245
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:
- 3479245-js-warning-about
changes, plain diff MR !12
Comments
Comment #2
kul.pratap commentedComment #4
kul.pratap commentedI have generated MR, Kindly check it.

No Warning after that.
Comment #5
kul.pratap commentedPlease check it (:
Comment #6
nk_ commentedThanks. 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
Comment #7
nk_ commentedComment #9
nk_ commentedPushed into 2.0.x-dev and is ready for testing.
Comment #10
tirupati_singh commentedHi @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!
Comment #11
bbu23Thanks.
Comment #13
bbu23Comment #14
dalinOooph.
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.