]> git.mxchange.org Git - friendica.git/commitdiff
Access image part of siteinfo only if $siteinfo["images"] is actually set. The current
authorVasudev Kamath <kamathvasudev@gmail.com>
Sun, 22 Jul 2012 07:11:07 +0000 (12:41 +0530)
committerVasudev Kamath <kamathvasudev@gmail.com>
Sun, 22 Jul 2012 07:11:07 +0000 (12:41 +0530)
code didn't check this so I was getting an error
     Warning: Invalid argument supplied for foreach() in /home/vasudev/Public/friendica/mod/parse_url.php on line 305

Implemented a check before accessing $siteinfo["images"] with this commit and now warning doesn't come when giving URL of a site which doesn't have image from link button of post area

mod/parse_url.php

index 0610531967db8e92b1d2587ce9aeb06c6809a8a8..5dd7de750b112b8b8f79aa094a79835e05833c1a 100644 (file)
@@ -302,11 +302,16 @@ function parse_url_content(&$a) {
 
        $image = "";
 
-       foreach ($siteinfo["images"] as $imagedata)
+        if($siteinfo["image"] != ""){
+            /*
+              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)