We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit dd229e85 authored by mattl's avatar mattl

Allow finding the "original remote thumbnail"

This will probably cause older oEmbed images not to show, since they
probably were updated to use empty url entries because they were thought
of as local ones. During a migration period maybe you want to change
the default value of notNullUrl to 'false' in File_thumbnail::byFile(...)
parent 893d8881
......@@ -85,13 +85,24 @@ class File_thumbnail extends Managed_DataObject
/**
* Fetch an entry by using a File's id
*
* @param File $file The File object we're getting a thumbnail for.
* @param boolean $notNullUrl Originally remote thumbnails have a URL stored, we use this to find the "original"
*
* @return File_thumbnail
* @throws NoResultException if no File_thumbnail matched the criteria
*/
static function byFile(File $file) {
$file_thumbnail = self::getKV('file_id', $file->getID());
if (!$file_thumbnail instanceof File_thumbnail) {
throw new ServerException(sprintf('No File_thumbnail entry for File id==%u', $file->getID()));
static function byFile(File $file, $notNullUrl=true) {
$thumb = new File_thumbnail();
$thumb->file_id = $file->getID();
if ($notNullUrl) {
$thumb->whereAdd('url IS NOT NULL');
}
$thumb->limit(1);
if (!$thumb->find(true)) {
throw new NoResultException($thumb);
}
return $file_thumbnail;
return $thumb;
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment