Skip to content

Commit

Permalink
Handled jetpack gallery markup
Browse files Browse the repository at this point in the history
Fixes #17
  • Loading branch information
robneu committed Aug 20, 2015
1 parent ea07280 commit aef4e1d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
16 changes: 10 additions & 6 deletions js/src/wpFeatherlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,17 @@
*/
function addCaptions() {
$.featherlight.prototype.afterContent = function() {
var object = this.$instance,
target = this.$currentTarget,
parent = target.parent(),
caption = parent.find( '.wp-caption-text' );
var object = this.$instance,
target = this.$currentTarget,
parent = target.parent(),
caption = parent.find( '.wp-caption-text' ),
galParent = target.parents( '.gallery-item' ),
jetParent = target.parents( '.tiled-gallery-item' );

if ( parent.hasClass( 'gallery-icon' ) ) {
caption = target.parents( '.gallery-item' ).find( '.wp-caption-text' );
if ( 0 !== galParent.length ) {
caption = galParent.find( '.wp-caption-text' );
} else if ( 0 !== jetParent.length ) {
caption = jetParent.find( '.tiled-gallery-caption' );
}

object.find( '.caption' ).remove();
Expand Down
2 changes: 1 addition & 1 deletion js/src/wpFeatherlight.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 11 additions & 7 deletions js/wpFeatherlight.pkgd.js
Original file line number Diff line number Diff line change
Expand Up @@ -852,13 +852,17 @@
*/
function addCaptions() {
$.featherlight.prototype.afterContent = function() {
var object = this.$instance,
target = this.$currentTarget,
parent = target.parent(),
caption = parent.find( '.wp-caption-text' );

if ( parent.hasClass( 'gallery-icon' ) ) {
caption = target.parents( '.gallery-item' ).find( '.wp-caption-text' );
var object = this.$instance,
target = this.$currentTarget,
parent = target.parent(),
caption = parent.find( '.wp-caption-text' ),
galParent = target.parents( '.gallery-item' ),
jetParent = target.parents( '.tiled-gallery-item' );

if ( 0 !== galParent.length ) {
caption = galParent.find( '.wp-caption-text' );
} else if ( 0 !== jetParent.length ) {
caption = jetParent.find( '.tiled-gallery-caption' );
}

object.find( '.caption' ).remove();
Expand Down
Loading

0 comments on commit aef4e1d

Please sign in to comment.