Skip to content

Commit

Permalink
Merge pull request #179 from obeyer/ob-pin-responsive
Browse files Browse the repository at this point in the history
Add support for tall pins
  • Loading branch information
Sigurður Guðbrandsson authored Apr 18, 2017
2 parents f9abb4f + 54cd7cc commit 5a00f64
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 5a00f64

Please sign in to comment.