Skip to content

Commit

Permalink
add support for tall pins
Browse files Browse the repository at this point in the history
  • Loading branch information
obeyer committed Mar 17, 2017
1 parent 77acbcb commit 54cd7cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/Pass/PinterestTagTransformPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,21 @@ protected function setPinterestDimensionsFrom(DOMQuery $el, DOMQuery $new_el)

$width = $el->attr('width');
$height = $el->attr('height');

if (!empty($height) && empty($width)) {
$width = 'auto';
}

$hw_available = !empty($width) && !empty($height);
$new_el->attr('data-pin-width', $pin_width);
if ($hw_available) {
$new_el->attr('width', $width);
$new_el->attr('height', $height);
} else {
$new_el->attr('layout', $width == 'auto' ? 'fixed-height' : 'fixed');
}
else {
$new_el->attr($dimensions[$pin_width]);
$new_el->attr('layout', 'responsive');
}
}
}
2 changes: 1 addition & 1 deletion tests/test-data/fragment-html/pinterest-fragment.html.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<amp-pinterest data-url="https://www.pinterest.com/pin/99360735500167749/" data-do="embedPin" data-pin-width="medium" width="345" height="426"></amp-pinterest>
<amp-pinterest data-url="https://www.pinterest.com/pin/99360735500167749/" data-do="embedPin" data-pin-width="medium" width="345" height="426" layout="responsive"></amp-pinterest>


ORIGINAL HTML
Expand Down

0 comments on commit 54cd7cc

Please sign in to comment.