Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi, based on commit hash 7c0b80fd23358f8afbd0d19d32f7b33d99f8b553 in flexslider_fields_field_formatter_view()
, the $element
array should have had a nested array of items so it looks like $element[] = ...
. Instead, the commit removes that line and is replaced with $element = ...
. As a result, a field output with flexslider looks more like
<div id="flexslider-1" class="flexslider">
<ul class="slides"><li><img typeof="foaf:Image" src="http://pitkin.chillco.dev:8082/sites/default/files/styles/hero_images/public/hero-page/Thanksgiving.jpg?itok=ehMgyZaA" width="350" height="350" alt="" title="No Teen Event November 27th- Happy Thanksgiving!" /><div class="flex-caption">No Teen Event November 27th- Happy Thanksgiving!</div></li>
<li><img typeof="foaf:Image" src="http://pitkin.chillco.dev:8082/sites/default/files/styles/hero_images/public/hero-page/The%20Great%20Gatsby%20Movie_0.jpg?itok=UW1w87Rf" width="233" height="350" alt="" title="November's Book-to-Film Screening: "The Great Gatsby"" /><div class="flex-caption">November's Book-to-Film Screening: "The Great Gatsby"</div></li>
<li><img typeof="foaf:Image" src="http://pitkin.chillco.dev:8082/sites/default/files/styles/hero_images/public/hero-page/IMG_3706_0.JPG?itok=RTt2xS6w" width="467" height="350" alt="" title="Halloween Fun at the Library- Cutie Pumpkins & Banana Ghosts" /><div class="flex-caption">Halloween Fun at the Library- Cutie Pumpkins & Banana Ghosts</div></li>
<li><img typeof="foaf:Image" src="http://pitkin.chillco.dev:8082/sites/default/files/styles/hero_images/public/hero-page/Gingerbread%20House%20Decorating%202013_0.jpg?itok=ngEuooV7" width="453" height="350" alt="" title="A Holiday Tradition at the Library- Coming this December!" /><div class="flex-caption">A Holiday Tradition at the Library- Coming this December!</div></li>
<li><img typeof="foaf:Image" src="http://pitkin.chillco.dev:8082/sites/default/files/styles/hero_images/public/hero-page/How%20I%20live%20now.jpg?itok=hblw4Wco" width="237" height="350" alt="" title="December's Teen Book of the Month Club Pick" /><div class="flex-caption">December's Teen Book of the Month Club Pick</div></li>
</ul></div>
<div class="field field-name-field-hero-images field-type-image field-label-hidden"><div class="field-items"><div class="field-item even"><div id="flexslider-1" class="flexslider">
<ul class="slides"><li><img typeof="foaf:Image" src="http://pitkin.chillco.dev:8082/sites/default/files/styles/hero_images/public/hero-page/Thanksgiving.jpg?itok=ehMgyZaA" width="350" height="350" alt="" title="No Teen Event November 27th- Happy Thanksgiving!" /><div class="flex-caption">No Teen Event November 27th- Happy Thanksgiving!</div></li>
<li><img typeof="foaf:Image" src="http://pitkin.chillco.dev:8082/sites/default/files/styles/hero_images/public/hero-page/The%20Great%20Gatsby%20Movie_0.jpg?itok=UW1w87Rf" width="233" height="350" alt="" title="November's Book-to-Film Screening: "The Great Gatsby"" /><div class="flex-caption">November's Book-to-Film Screening: "The Great Gatsby"</div></li>
<li><img typeof="foaf:Image" src="http://pitkin.chillco.dev:8082/sites/default/files/styles/hero_images/public/hero-page/IMG_3706_0.JPG?itok=RTt2xS6w" width="467" height="350" alt="" title="Halloween Fun at the Library- Cutie Pumpkins & Banana Ghosts" /><div class="flex-caption">Halloween Fun at the Library- Cutie Pumpkins & Banana Ghosts</div></li>
<li><img typeof="foaf:Image" src="http://pitkin.chillco.dev:8082/sites/default/files/styles/hero_images/public/hero-page/Gingerbread%20House%20Decorating%202013_0.jpg?itok=ngEuooV7" width="453" height="350" alt="" title="A Holiday Tradition at the Library- Coming this December!" /><div class="flex-caption">A Holiday Tradition at the Library- Coming this December!</div></li>
<li><img typeof="foaf:Image" src="http://pitkin.chillco.dev:8082/sites/default/files/styles/hero_images/public/hero-page/How%20I%20live%20now.jpg?itok=hblw4Wco" width="237" height="350" alt="" title="December's Teen Book of the Month Club Pick" /><div class="flex-caption">December's Teen Book of the Month Club Pick</div></li>
</ul></div>
</div></div></div>
missing all the outside divs. While not suffering from divitis is a noble goal, I think that is better left to field level overrides or semantic field module or somesuch (ie it can be overridden someplace) than in a field view formatter.
Comment | File | Size | Author |
---|---|---|---|
#1 | 2140663.patch | 520 bytes | BTMash |
Comments
Comment #1
BTMash CreditAttribution: BTMash commentedAttaching patch.
Comment #2
minorOffense CreditAttribution: minorOffense commentedWe did so on purpose to ensure that the field templates/styles didn't get in the way of the flexslider instance.
I'm debating that decision now but still leaning towards omitting the field template unless someone can provide a reason or use case to include them.
I realize that fences or other modules can help reduce the markup, but why not have FlexSlider just set the markup as required?
Comment #3
BTMash CreditAttribution: BTMash commentedIn my case, part of the issue came up with how the css by the designer had been set up - it was targeting a field instance (instead of the flexslider by id) to apply the necessary markup and adjustments. With the removal of the field templates, it required adjustment (and made it less flexible when different fields using flexslider on the site that need to look different now look similar to each other since there is no other contextual information regarding the flexslider instance (if that makes any sense).
Comment #4
minorOffense CreditAttribution: minorOffense commentedYou could restore the templates from earlier versions into your theme and restore the wrapping elements.
As for rendering multiple fields with different styles, I'll mull that over and see if I can find a solution that meets both our requirements. (maybe has a field setting to add a class or get the field classes and put them on the container)
But I won't put the field template wrapping stuff back in.
Comment #5
BTMash CreditAttribution: BTMash commentedI'm not wholly understanding what the workaround is supposed to be when the changes have happened in
flexslider_fields_field_formatter_view
Comment #6
TommyK CreditAttribution: TommyK commentedAbility to add a class in the field settings would help immensely to style flexsliders differently.
Use case:
We have 2 different image fields on a content type. One for a single "main image" and one for multiple "slideshow images". If we use one or the other they each get a "flexslider-1" ID when they are used.
Comment #7
troybthompson CreditAttribution: troybthompson commentedI have the same issue, two image fields, one formatted as a callout, and one full width. I have to go through css contortions to try to specify which one I want. Is there any other field formatter that erases the field class? I don't see the advantage of removing standard information. If someone happens to use css that breaks the slideshow, they should have the knowledge to fix it. If someone decides to change a static image to a slideshow, currently all the formatting targeted for that field breaks.