cycle2 icon indicating copy to clipboard operation
cycle2 copied to clipboard

Somehow pager thumbnails doesn't show correct src path

Open ianthedev opened this issue 11 years ago • 7 comments
trafficstars

I'm trying to create pager thumbnails like the Advanced Custom Template shows. Here is my code:

$('.selector').cycle({
    // other options
    pagerTemplate : '<a><img src="{{src}}" alt=""></a>'
});


The slide works. But somehow the HTML code of each thumbnail becomes:

<a><img src="src" alt=""></a>

ianthedev avatar Apr 13 '14 11:04 ianthedev

By the way, I'm using Non-Image Slides so the original images are inside <li>s, which are the slides.

ianthedev avatar Apr 13 '14 12:04 ianthedev

This might help:

http://jquery.malsup.com/cycle2/demo/tmpl2.php

malsup avatar Apr 13 '14 21:04 malsup

Just tried:

$('.selector').cycle({
    // other options
    pagerTemplate : '<a><img src="{{firstChild.src}}" alt=""></a>'
});


The result becomes:

<a><img src="firstChild.src" alt=""></a>

ianthedev avatar Apr 14 '14 01:04 ianthedev

I'm running into this issue now. I'm using Cycle2 to convert an unordered list generated by my CMS to a slideshow. As such, I can't add data-cycle attributes to my markup. I tried the {{firstChild.src}} placeholders in my pagerTemplate option and got the same result as above.

Has anyone solved this or can I get some direction?

adamwhitley avatar Jul 06 '16 12:07 adamwhitley

Found it.

I used the API.customGetImageSrc method in a mustache template:

pagerTemplate: '<li><a href="#"><img src="{{API.customGetImageSrc}}" width=20 height=20></a></li>'

Then I just used that function to get the image from the slide. Not sure why methods like {{firstChild.src}} aren't working in this case, but this solution should get anyone with this issue off the ground.

adamwhitley avatar Jul 06 '16 13:07 adamwhitley

Another way around this issue is to use {{children.0.src}} in place of {{firstChild.src}}. I too was having issues with {{firstChild.src}} rendering as <img src="firstChild.src">.

greyskin avatar Jun 01 '19 05:06 greyskin

For some reason none of the above is working for me currently. They are all treated as string. I'm using the JS to trigger the slide (not HTML markup).. antyhing I'm missing here?

moseleyi avatar Mar 05 '20 09:03 moseleyi