]> git.mxchange.org Git - friendica.git/blobdiff - mod/parse_url.php
Frost-mobile: media query in css for tablets
[friendica.git] / mod / parse_url.php
index 32f28b7b7bce3c6f67d6260e97e7f74147c6d1e1..ea05055f0cefc69b461c29b5e009786320bcc2b8 100644 (file)
@@ -1,4 +1,18 @@
 <?php
+/* To-Do
+https://developers.google.com/+/plugins/snippet/
+
+<meta itemprop="name" content="Toller Titel">
+<meta itemprop="description" content="Eine tolle Beschreibung">
+<meta itemprop="image" content="http://maple.libertreeproject.org/images/tree-icon.png">
+
+<body itemscope itemtype="http://schema.org/Product">
+  <h1 itemprop="name">Shiny Trinket</h1>
+  <img itemprop="image" src="{image-url}" />
+  <p itemprop="description">Shiny trinkets are shiny.</p>
+</body>
+*/
+
 if(!function_exists('deletenode')) {
        function deletenode(&$doc, $node)
        {
@@ -147,11 +161,11 @@ function parseurl_getsiteinfo($url) {
 
                        if (($photodata[0] > 150) and ($photodata[1] > 150)) {
                                if ($photodata[0] > 300) {
-                                       $photodata[1] = $photodata[1] * (300 / $photodata[0]);
+                                       $photodata[1] = round($photodata[1] * (300 / $photodata[0]));
                                        $photodata[0] = 300;
                                }
                                if ($photodata[1] > 300) {
-                                       $photodata[0] = $photodata[0] * (300 / $photodata[1]);
+                                       $photodata[0] = round($photodata[0] * (300 / $photodata[1]));
                                        $photodata[1] = 300;
                                }
                                $siteinfo["images"][] = array("src"=>$src,
@@ -162,6 +176,9 @@ function parseurl_getsiteinfo($url) {
                 }
         } else {
                $src = completeurl($siteinfo["image"], $url);
+
+               unset($siteinfo["image"]);
+
                $photodata = getimagesize($src);
 
                if (($photodata[0] > 10) and ($photodata[1] > 10))
@@ -278,8 +295,7 @@ function parse_url_content(&$a) {
        $siteinfo = parseurl_getsiteinfo($url);
 
        if($siteinfo["title"] == "") {
-               echo print_r($siteinfo, true);
-               //echo sprintf($template,$url,$url,'') . $str_tags;
+               echo sprintf($template,$url,$url,'') . $str_tags;
                killme();
        } else {
                $text = $siteinfo["text"];
@@ -288,11 +304,16 @@ function parse_url_content(&$a) {
 
        $image = "";
 
-       foreach ($siteinfo["images"] as $imagedata)
+        if(sizeof($siteinfo["images"]) > 0){
+            /*
+              Execute below code only if image is present in siteinfo
+             */
+            foreach ($siteinfo["images"] as $imagedata)
                if($textmode)
-                       $image .= '[img='.$imagedata["width"].'x'.$imagedata["height"].']'.$imagedata["src"].'[/img]';
+                    $image .= '[img='.$imagedata["width"].'x'.$imagedata["height"].']'.$imagedata["src"].'[/img]';
                else
-                       $image .= '<img height="'.$imagedata["height"].'" width="'.$imagedata["width"].'" src="'.$imagedata["src"].'" alt="photo" />';
+                    $image .= '<img height="'.$imagedata["height"].'" width="'.$imagedata["width"].'" src="'.$imagedata["src"].'" alt="photo" />';
+        }
 
        if(strlen($text)) {
                if($textmode)