0

I'm using ExpressionEngine and have a wygwam field that takes html formatting, including img tags. I was wondering how I could dynamically create a swiper based on these images? I was thinking that if the field contains more than one image, it should be turned into a slideshow.

I could do this with some jQuery, check the text for img tags and edit the markup, then initialize the swiper instance. But could this be done using perhaps embedded templates, or even snippets? Or perhaps there's a plugin out there for this need?

2 Answers 2

1

You could use another field type for the images in the post. Grid would be one that would work without going to a third-party resource. Channel Images is a solid commercial addon that handles multiple images in an entry really well.

2
  • Yeah, well I'm also using assets, so isn't that kinda the same thing? Feb 20, 2014 at 8:33
  • I agree with rchrdg - a separate field grouo would be a much cleaner way of achieving a swiper. EE is built for controlling content take advantage of it. May 21, 2014 at 13:15
0

I'm pretty sure there is an option to add a div in a wygwam field (check in the module settings, you may need to enable it).

With that option, add your images, highlight them, and add the wrapping div/s. You're also given a dialog box to give the div(s) attributes, like class and ID, etc. I noticed swiper is like most slideshows in its set up:

<div class="container">
<div class="wrapper">
<div class="slide"> <img src="img/image1.png"> </div>
<div class="slide"> <img src="img/image2.png"> </div>
</div><!-- /.wrapper -->
</div><!-- /.container -->

Doing this with Wygwam can be a little fiddly but it should be possible.

There is also the option to add a 'Source' button to edit the html directly. You can also get pretty advance with Wygwam and create your own formatting buttons, but that's a bit much to go in to here...

Agreed, if this is something you plan to use often in a pre determined space, a grid field would be a better option.

1
  • You can probably add an "swiper" item to the styles menu, and have it insert a div with predefined swipe class or something to that extent.
    – GDmac
    Feb 16, 2015 at 9:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.