From 54cd7cc5dae338d3c90e51078776f3f7b599a96b Mon Sep 17 00:00:00 2001 From: Olena Beyer Date: Thu, 16 Mar 2017 16:43:09 -0700 Subject: [PATCH] add support for tall pins --- src/Pass/PinterestTagTransformPass.php | 10 +++++++++- .../fragment-html/pinterest-fragment.html.out | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Pass/PinterestTagTransformPass.php b/src/Pass/PinterestTagTransformPass.php index 30827311..51a8a38d 100644 --- a/src/Pass/PinterestTagTransformPass.php +++ b/src/Pass/PinterestTagTransformPass.php @@ -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'); } } } diff --git a/tests/test-data/fragment-html/pinterest-fragment.html.out b/tests/test-data/fragment-html/pinterest-fragment.html.out index 8aeab260..fd5b62a7 100644 --- a/tests/test-data/fragment-html/pinterest-fragment.html.out +++ b/tests/test-data/fragment-html/pinterest-fragment.html.out @@ -1,4 +1,4 @@ - + ORIGINAL HTML