mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 23:55:19 +00:00
Support and import alt-text supplied by opengraph or image attributes when parsing external links
This commit is contained in:
parent
27fb8296cd
commit
93f9add9dc
1 changed files with 13 additions and 2 deletions
|
@ -548,6 +548,9 @@ class Linkinfo extends Controller
|
||||||
case "og:image":
|
case "og:image":
|
||||||
$siteinfo["image"] = $attr["content"];
|
$siteinfo["image"] = $attr["content"];
|
||||||
break;
|
break;
|
||||||
|
case "og:image:alt":
|
||||||
|
$siteinfo["image_alt"] = $attr["content"];
|
||||||
|
break;
|
||||||
case "og:title":
|
case "og:title":
|
||||||
$siteinfo["title"] = $attr["content"];
|
$siteinfo["title"] = $attr["content"];
|
||||||
break;
|
break;
|
||||||
|
@ -568,6 +571,7 @@ class Linkinfo extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$src = self::completeurl($attr["src"], $url);
|
$src = self::completeurl($attr["src"], $url);
|
||||||
|
$alt = $attr["alt"];
|
||||||
$photodata = @getimagesize($src);
|
$photodata = @getimagesize($src);
|
||||||
|
|
||||||
if (($photodata) && ($photodata[0] > 150) and ($photodata[1] > 150)) {
|
if (($photodata) && ($photodata[0] > 150) and ($photodata[1] > 150)) {
|
||||||
|
@ -581,7 +585,9 @@ class Linkinfo extends Controller
|
||||||
}
|
}
|
||||||
$siteinfo["images"][] = ["src" => $src,
|
$siteinfo["images"][] = ["src" => $src,
|
||||||
"width" => $photodata[0],
|
"width" => $photodata[0],
|
||||||
"height" => $photodata[1]];
|
"height" => $photodata[1],
|
||||||
|
"alt" => ($alt ?? "")
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -589,12 +595,17 @@ class Linkinfo extends Controller
|
||||||
|
|
||||||
unset($siteinfo["image"]);
|
unset($siteinfo["image"]);
|
||||||
|
|
||||||
|
$alt = $siteinfo["image_alt"];
|
||||||
|
unset($siteinfo["image_alt"]);
|
||||||
|
|
||||||
$photodata = @getimagesize($src);
|
$photodata = @getimagesize($src);
|
||||||
|
|
||||||
if (($photodata) && ($photodata[0] > 10) and ($photodata[1] > 10)) {
|
if (($photodata) && ($photodata[0] > 10) and ($photodata[1] > 10)) {
|
||||||
$siteinfo["images"][] = ["src" => $src,
|
$siteinfo["images"][] = ["src" => $src,
|
||||||
"width" => $photodata[0],
|
"width" => $photodata[0],
|
||||||
"height" => $photodata[1]];
|
"height" => $photodata[1],
|
||||||
|
"alt" => ($alt ?? '')
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue