Skip to content

Commit

Permalink
Merge pull request #1187 from Automattic/fix/gallery
Browse files Browse the repository at this point in the history
Fix adding images to AMP carousel gallery
  • Loading branch information
westonruter authored May 31, 2018
2 parents a15be99 + 1eb542e commit 64de118
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions includes/sanitizers/class-amp-gallery-block-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,24 @@ public function sanitize() {
continue;
}

$images = null;
$images = array();

// If it's not AMP lightbox, look for links first.
if ( ! $is_amp_lightbox ) {
$images = $node->getElementsByTagName( 'a' );
foreach ( $node->getElementsByTagName( 'a' ) as $element ) {
$images[] = $element;
}
}

// If not linking to anything then look for <amp-img>.
if ( ! $images || 0 === $images->length ) {
$images = $node->getElementsByTagName( 'amp-img' );
if ( empty( $images ) ) {
foreach ( $node->getElementsByTagName( 'amp-img' ) as $element ) {
$images[] = $element;
}
}

// Skip if no images found.
if ( ! $images || 0 === $images->length ) {
if ( empty( $images ) ) {
continue;
}

Expand Down

0 comments on commit 64de118

Please sign in to comment.