diff --git a/src/AMP.php b/src/AMP.php
index e852ade7..7d3d94f9 100644
--- a/src/AMP.php
+++ b/src/AMP.php
@@ -51,6 +51,8 @@ class AMP
public $passes = [
'Lullabot\AMP\Pass\PreliminaryPass', // Removes user blacklisted tags
'Lullabot\AMP\Pass\ImgTagTransformPass',
+ 'Lullabot\AMP\Pass\ImgurTransformPass',
+ 'Lullabot\AMP\Pass\TumblrTransformPass',
'Lullabot\AMP\Pass\IframeSoundCloudTagTransformPass',
'Lullabot\AMP\Pass\IframeFacebookTagTransformPass',
'Lullabot\AMP\Pass\AudioTagTransformPass',
diff --git a/src/Pass/ImgTagTransformPass.php b/src/Pass/ImgTagTransformPass.php
index 8e28efeb..74a00b97 100644
--- a/src/Pass/ImgTagTransformPass.php
+++ b/src/Pass/ImgTagTransformPass.php
@@ -175,6 +175,19 @@ protected function getImageWidthHeight($src)
// Try obtaining image size without having to download the whole image
$size = $this->fastimage->getImageSize($img_url);
+
+ if (!$size) {
+ // Now try with downloading the whole image
+ list($width, $height) = @getimagesize($src);
+
+ if ($width && $height) {
+ $size = [
+ 'width' => $width,
+ 'height' => $height,
+ ];
+ }
+ }
+
return $size;
}
diff --git a/src/Pass/ImgurTransformPass.php b/src/Pass/ImgurTransformPass.php
new file mode 100644
index 00000000..58a3bffa
--- /dev/null
+++ b/src/Pass/ImgurTransformPass.php
@@ -0,0 +1,59 @@
+q->top()->find('blockquote.imgur-embed-pub');
+ /** @var DOMQuery $el */
+ foreach ($all_imgur as $el) {
+ /** @var \DOMElement $dom_el */
+ $dom_el = $el->get(0);
+ $lineno = $this->getLineNo($dom_el);
+ $context_string = $this->getContextString($dom_el);
+
+ /** @var \DOMElement $new_dom_el */
+ $imgur_id = $el->attr('data-id');
+ $img_src = 'https://i.imgur.com/' . $imgur_id . '.png';
+ $size = $this->getImageWidthHeight($img_src);
+
+ if (!$size) {
+ $size['height'] = 400;
+ $size['width'] = 400;
+ }
+
+ $amp_string =<<<"HTML"
+
+
+
+
Another victory - it fits!
diff --git a/tests/test-data/fragment-html/img-test-fragment.html.out b/tests/test-data/fragment-html/img-test-fragment.html.out
index 20a30bb1..204ba458 100644
--- a/tests/test-data/fragment-html/img-test-fragment.html.out
+++ b/tests/test-data/fragment-html/img-test-fragment.html.out
@@ -27,6 +27,11 @@
Line 29:
+Line 30:
+Line 31: Another victory - it fits!
+Line 32:
Transformations made from HTML tags to AMP custom tags
@@ -79,6 +87,9 @@ Transformations made from HTML tags to AMP custom tags
at line 28
ACTION TAKEN: img tag was converted to the amp-img tag.
+ at line 31
+ ACTION TAKEN: blockquote.imgur imgur tag was converted to the amp-iframe tag
+
AMP-HTML Validation Issues and Fixes
-------------------------------------
@@ -110,4 +121,5 @@ FAIL
COMPONENT NAMES WITH JS PATH
------------------------------
-No custom amp script includes required
+'amp-iframe', include path 'https://cdn.ampproject.org/v0/amp-iframe-0.1.js'
+
diff --git a/tests/test-data/fragment-html/tumblr-fragment.html b/tests/test-data/fragment-html/tumblr-fragment.html
new file mode 100644
index 00000000..c88611f4
--- /dev/null
+++ b/tests/test-data/fragment-html/tumblr-fragment.html
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/tests/test-data/fragment-html/tumblr-fragment.html.out b/tests/test-data/fragment-html/tumblr-fragment.html.out
new file mode 100644
index 00000000..002e693e
--- /dev/null
+++ b/tests/test-data/fragment-html/tumblr-fragment.html.out
@@ -0,0 +1,24 @@
+
+
+
+ORIGINAL HTML
+---------------
+Line 1:
+Line 2:
+
+
+Transformations made from HTML tags to AMP custom tags
+-------------------------------------------------------
+
+ at line 1
+ ACTION TAKEN: a (with associated script tag) tumblr tag was converted to the amp-iframe tag
+
+
+AMP-HTML Validation Issues and Fixes
+-------------------------------------
+PASS
+
+COMPONENT NAMES WITH JS PATH
+------------------------------
+'amp-iframe', include path 'https://cdn.ampproject.org/v0/amp-iframe-0.1.js'
+