summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2015-05-15 08:06:18 +0300
committerAndrew Dolgov <[email protected]>2015-05-15 08:06:18 +0300
commit299aeb30946a07100567fbd3de05a8b3f6dd5894 (patch)
tree0da052fc929eac083b045bb367b9189140ba2baf /plugins
parentc68013b132fcf273a7b7d1b812b38b213fa369f9 (diff)
af_redditimgur: gifv: fix iframe not being wide enough, fix indenting
Diffstat (limited to 'plugins')
-rw-r--r--plugins/af_redditimgur/init.php95
1 files changed, 48 insertions, 47 deletions
diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php
index 4521eae8c..7e65ef74b 100644
--- a/plugins/af_redditimgur/init.php
+++ b/plugins/af_redditimgur/init.php
@@ -28,55 +28,56 @@ class Af_RedditImgur extends Plugin {
foreach ($entries as $entry) {
if ($entry->hasAttribute("href")) {
-
+
if (preg_match("/\.(gifv)$/i", $entry->getAttribute("href"))) {
- $gifv_meta = fetch_file_contents($entry->getAttribute("href"),
- false, false, false, false, 10);
-
- if ($gifv_meta) {
- $adoc = new DOMDocument();
- @$adoc->loadHTML($gifv_meta);
-
- if ($adoc) {
- $axpath = new DOMXPath($adoc);
- $aentries = $axpath->query('(//meta)');
-
- $width = false;
- $height = false;
-
- foreach ($aentries as $aentry) {
- if (strpos($aentry->getAttribute("property"), "og:image:width") !== FALSE) {
- $width = $aentry->getAttribute("content");
- }
- if (strpos($aentry->getAttribute("property"), "og:image:height") !== FALSE) {
- $height = $aentry->getAttribute("content");
- }
- }
- }
- }
-
- if ($width && $height) {
-
- $iframe = $doc->createElement('iframe');
- $iframe->setAttribute("src", str_replace("http:", "", $entry->getAttribute("href")));
- $iframe->setAttribute("frameborder", "0");
- $iframe->setAttribute("width", $width);
- $iframe->setAttribute("height", $height);
-
- $br = $doc->createElement('br');
- $entry->parentNode->insertBefore($iframe, $entry);
- $entry->parentNode->insertBefore($br, $entry);
-
- // add empty img tag to disable display of attachment
- $img = $doc->createElement('img');
- $img->setAttribute("src", "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D");
- $img->setAttribute("width", "0");
- $img->setAttribute("height", "0");
- $entry->parentNode->insertBefore($img, $entry);
- $found = true;
- }
- }
+ $gifv_meta = fetch_file_contents($entry->getAttribute("href"),
+ false, false, false, false, 10);
+
+ if ($gifv_meta) {
+ $adoc = new DOMDocument();
+ @$adoc->loadHTML($gifv_meta);
+
+ if ($adoc) {
+ $axpath = new DOMXPath($adoc);
+ $aentries = $axpath->query('(//meta)');
+
+ $width = false;
+ $height = false;
+
+ foreach ($aentries as $aentry) {
+ if (strpos($aentry->getAttribute("property"), "og:image:width") !== FALSE) {
+ $width = $aentry->getAttribute("content");
+ }
+
+ if (strpos($aentry->getAttribute("property"), "og:image:height") !== FALSE) {
+ $height = $aentry->getAttribute("content");
+ }
+ }
+ }
+ }
+
+ if ($width && $height) {
+
+ $iframe = $doc->createElement('iframe');
+ $iframe->setAttribute("src", str_replace("http:", "", $entry->getAttribute("href")));
+ $iframe->setAttribute("frameborder", "0");
+ $iframe->setAttribute("width", $width + 64);
+ $iframe->setAttribute("height", $height + 64);
+
+ $br = $doc->createElement('br');
+ $entry->parentNode->insertBefore($iframe, $entry);
+ $entry->parentNode->insertBefore($br, $entry);
+
+ // add empty img tag to disable display of attachment
+ $img = $doc->createElement('img');
+ $img->setAttribute("src", "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D");
+ $img->setAttribute("width", "0");
+ $img->setAttribute("height", "0");
+ $entry->parentNode->insertBefore($img, $entry);
+ $found = true;
+ }
+ }
if (preg_match("/\.(jpg|jpeg|gif|png)(\?[0-9])?$/i", $entry->getAttribute("href"))) {