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

Added alt support #355

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added alt tag support
Grabs the alt tag from the gallery images and adds it to the featured image tags.
  • Loading branch information
mahowa authored Mar 4, 2018
commit 9cfcbafd8668e7be64c459bf72593427018ede0e
27 changes: 20 additions & 7 deletions src/js/jquery.swipebox.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@
}

$elem.each( function() {

var img = $(this).children()[0];

var title = null,
href = null;
href = null,
alt = null;

if ( $( this ).attr( 'title' ) ) {
title = $( this ).attr( 'title' );
Expand All @@ -125,9 +127,14 @@
href = $( this ).attr( 'href' );
}

if ( $( img).attr( 'alt' ) ) {
alt = $( img ).attr( 'alt' );
}

elements.push( {
href: href,
title: title
title: title,
alt: alt
} );
} );

Expand Down Expand Up @@ -670,10 +677,13 @@
openMedia : function ( index ) {
var $this = this,
src,
slide;
slide,
alt;

if ( elements[ index ] !== undefined ) {
src = elements[ index ].href;
var elm = elements[ index ];
src = elm.href;
alt = elm.alt;
}

if ( index < 0 || index >= elements.length ) {
Expand All @@ -686,14 +696,17 @@
slide.addClass( 'slide-loading' );
$this.loadMedia( src, function() {
slide.removeClass( 'slide-loading' );
slide.html( this );
var html = this;
html[0].alt = alt;
slide.html( html );

if ( plugin.settings.afterMedia ) {
plugin.settings.afterMedia( index );
}
} );
} else {
slide.html( $this.getVideo( src ) );
var html = $this.getVideo( src );
slide.html( html );

if ( plugin.settings.afterMedia ) {
plugin.settings.afterMedia( index );
Expand Down