diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-05-26 17:28:12 -0400 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-05-26 17:28:12 -0400 |
commit | 0b53a820c2b4224b66b2a24f67302b4c5ca1deed (patch) | |
tree | 67086e31a9437327898920996bede11c1668f0e2 /lib/util.php | |
parent | 40d4668c7c5cdd41d36b878ad87f7737117efc9c (diff) | |
parent | c93031c2aa49b8a044e896ca1e07f5f4f429308e (diff) |
Merge branch '0.8.x' of git@gitorious.org:laconica/dev into 0.8.x
Diffstat (limited to 'lib/util.php')
-rw-r--r-- | lib/util.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/util.php b/lib/util.php index fbef8764a..d56f44f7b 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); } |