]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/util.php
start using design object
[quix0rs-gnu-social.git] / lib / util.php
index fbef8764a783fa60b2df42f76f72fb7a537bc40d..d56f44f7b45c39a948f8cd4ed488eb081ff783a1 100644 (file)
@@ -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);
 }