Skip to content

Instantly share code, notes, and snippets.

View WilliamIsted's full-sized avatar

William Isted WilliamIsted

View GitHub Profile
https://jsperf.com/check-jquery-getelementbyid
@WilliamIsted
WilliamIsted / Craft CMS Image Alt Text
Last active April 3, 2019 22:38
Craft CMS - Show image alt text if it has been set and isn't autogenerated
<img{% if image.title | kebab != image.slug %} alt="{{ image.title }}"{% endif %} src="{{ image.getUrl('thumb') }}">
Example Usage:
{% if entry.images | length %}
{% for image in entry.images %}
<img{% if image.title | kebab != image.slug %} alt="{{ image.title }}"{% endif %} src="{{ image.getUrl('thumb') }}">
{% endfor %}
{% endif %}
@WilliamIsted
WilliamIsted / Slick height fix
Last active August 25, 2016 10:17
Fix for when a slider has broken positioning from being previously hidden
jQuery(function($) {
$(document).on( 'click', '.tab', function() {
$('.slick')
.find('.news-item')
.css({ height: '' }) // Remove the height calculated when hidden
.find('.news-item__title')
.css({ height: '' }); // Remove the height calculated when hidden
$('.slick').slick('getSlick').checkResponsive(); // Trigger same internal functions as `orientationchange` event.