Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Image carousel - full caption display / functionality #1124

Closed
wants to merge 7 commits into from

Conversation

drawcard
Copy link
Contributor

@drawcard drawcard commented Jan 6, 2017

I noticed that there was no ability to show captions for images inserted into the Image Carousel widget, so I have written this functionality. The code itself is based on the caption functionality found in the Image Gallery widget, so for all intents and purposes it functions exactly the same.

The caption is currently inserted as a <figcaption> element directly inside .slick-slide-inner. Full typographic control can be made on that element (eg color, font size, alignment etc). The content of the caption is sourced from the Media Library "Caption" attribute, just like in the Image Gallery widget.

Some basic testing has been done - the only limitation is that the slick.js slide height sets itself to the entirety of the caption + image space. So if there is a particularly lengthy caption in one image, it will create a void underneath the other less lengthy slides. However this also ensures the content beneath the slide doesn't bounce around as different slide heights are brought into view.

This limitation could be solved with better CSS styling (or relocating figcaption to a better place in the markup), but the current solution works for now.

Please suggest ideas / improvements!

TO-DO / WISHLIST

  • Add an option to toggle absolute positioning on/off - so that it can be placed over an image, maybe with adjustable background colour / opacities to make it readable. This would also solve the slide height limitation.
  • Implement @ramiy 's suggestion of alternate text entry options

SCREENSHOTS

Front end:
image

image
(Note the gap between the slide image, captions, and controls, caused by the limitation described above. Not a huge issue for most users I imagine, it's only if you happen to abuse the caption feature by adding loads of text...)

image
Works responsively too

image

Code structure:
image

Backend controls:
image

image

@ramiy
Copy link
Contributor

ramiy commented Jan 25, 2017

@drawcard
The widget can be improved using a select field with 4 options: None, Title, Caption, Description.
This way the user can choose what text to show.

@drawcard
Copy link
Contributor Author

@ramiy that's a good idea, I'm not exactly sure how I can implement that so it might be a job for one of the senior devs.

@KingYes
Copy link
Member

KingYes commented Jan 26, 2017

Merged by this PR: #1229

Thanks! 👍

@KingYes KingYes closed this Jan 26, 2017
@soniapello
Copy link

@KingYes Will it be added to the next released 1.1.7 or before ?

@KingYes
Copy link
Member

KingYes commented Jan 26, 2017

v1.2.0

@carasmo
Copy link
Contributor

carasmo commented Apr 25, 2017

When I have the caption turned off on the image carousel, the caption tags still print and show any padding or margin applied to figcaption in the theme. I made a PR.

			$caption_type = $this->get_settings( 'caption_type' );

				if ( '' === $caption_type ) {

					$carosel_caption = '';
					
				} else {
				
					$carosel_caption = '<figcaption class="elementor-image-carousel-caption">' . $image_caption . '</figcaption>';
				
				}
				
			$slides[] = '<div class="slick-slide"><figure class="slick-slide-inner">' . $image_html . '' . $carosel_caption . '</figure></div>';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants