X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Futil.php;h=d56f44f7b45c39a948f8cd4ed488eb081ff783a1;hb=b3628b78448266fda2368f1317e70d1cca45ac17;hp=fbef8764a783fa60b2df42f76f72fb7a537bc40d;hpb=8d68c5238dfed8872e8ef3bf128d018cc974cdab;p=quix0rs-gnu-social.git diff --git a/lib/util.php b/lib/util.php index fbef8764a7..d56f44f7b4 100644 --- a/lib/util.php +++ b/lib/util.php @@ -496,6 +496,27 @@ function common_linkify($url) { } $attrs = array('href' => $longurl, 'rel' => 'external'); + +// if this URL is an attachment, then we set class='attachment' and id='attahcment-ID' +// where ID is the id of the attachment for the given URL. + $query = "select file_oembed.file_id as file_id from file join file_oembed on file.id = file_oembed.file_id where file.url='$longurl'"; + $file = new File; + $file->query($query); + $file->fetch(); + + if (!empty($file->file_id)) { + $query = "select file_thumbnail.file_id as file_id from file join file_thumbnail on file.id = file_thumbnail.file_id where file.url='$longurl'"; + $file2 = new File; + $file2->query($query); + $file2->fetch(); + + if (empty($file2->file_id)) { + $attrs['class'] = 'attachment'; + } else { + $attrs['class'] = 'attachment thumbnail'; + } + $attrs['id'] = "attachment-{$file->file_id}"; + } return XMLStringer::estring('a', $attrs, $display); }