Dynamically generate thumbnails (see full text)

The File object now stores width and height of files that can
supply this kind of information. Formats which we can not read
natively in PHP do not currently benefit from this. However an
event hook will be introduced later.

The CreateFileImageThumbnail event is renamed to:
CreateFileImageThumbnailSource to clarify that the hooks should not
generate their own thumbnails but only the source image. Also it now
accepts File objects, not MediaFile objects.

The thumbnail generation is documented in the source code. For
developers, call 'getThumbnail' on a File object and hope for the best.

Default thumbnail sizes have increased to be more appealing.
This commit is contained in:
Mikael Nordfeldth
2014-04-21 20:39:28 +02:00
parent 7f3611c51c
commit d59eb5e184
14 changed files with 238 additions and 178 deletions

View File

@@ -190,8 +190,8 @@ class BookmarkForm extends Form
function scaleImage($width, $height)
{
$maxwidth = common_config('attachments', 'thumb_width');
$maxheight = common_config('attachments', 'thumb_height');
$maxwidth = common_config('thumbnail', 'width');
$maxheight = common_config('thumbnail', 'height');
if ($width > $height && $width > $maxwidth) {
$height = (int) ((((float)$maxwidth)/(float)($width))*(float)$height);

View File

@@ -44,7 +44,7 @@ class VideoThumbnailsPlugin extends Plugin
* and disregard any cropping or scaling in the resulting file, as
* that will be handled in the core thumbnail algorithm.
*/
public function onCreateFileImageThumbnailSource(MediaFile $file, &$imgPath, $media=null)
public function onCreateFileImageThumbnailSource(File $file, &$imgPath, $media=null)
{
// The calling function might accidentally pass application/ogg videos.
// If that's a problem, let's fix it in the calling function.