diff --git a/docs/building-extensions/plugins/plugin-examples/filesystem-plugin-ftp.md b/docs/building-extensions/plugins/plugin-examples/filesystem-plugin-ftp.md index a746a755..2c9ac0a2 100644 --- a/docs/building-extensions/plugins/plugin-examples/filesystem-plugin-ftp.md +++ b/docs/building-extensions/plugins/plugin-examples/filesystem-plugin-ftp.md @@ -436,12 +436,16 @@ class FtpAdapter implements AdapterInterface $obj->modified_date = $obj->create_date; $obj->modified_date_formatted = $obj->create_date_formatted; $obj->mime_type = $file['type'] == 'file' ? $this->extension_mime_mapper(strrchr($file['name'], ".")) : "directory"; - if ($obj->mime_type == 'image/png' || $obj->mime_type == 'image/jpeg') { - $obj->thumb_path = Uri::root() . "images/powered_by.png"; - } $obj->width = 0; $obj->height = 0; - + + // Add thumbnail preview when possible. Recomended size: should fit in to 200x200px box. + // Relative or full path. + $obj->thumb_path = Uri::root(true) . '/images/powered_by.png'; + // Optional, an actual size of thumbnail to enable lazy loading + $obj->thumb_width = 200; + $obj->thumb_height = 44; + return $obj; } } @@ -520,12 +524,16 @@ class FtpAdapter implements AdapterInterface $obj->modified_date = $obj->create_date; $obj->modified_date_formatted = $obj->create_date_formatted; $obj->mime_type = $file['type'] == 'file' ? $this->extension_mime_mapper(strrchr($file['name'], ".")) : "directory"; - if ($obj->mime_type == 'image/png' || $obj->mime_type == 'image/jpeg') { - $obj->thumb_path = Uri::root() . "images/powered_by.png"; - } $obj->width = 0; $obj->height = 0; - + + // Add thumbnail preview when possible. Recomended size: should fit in to 200x200px box. + // Relative or full path. + $obj->thumb_path = Uri::root(true) . '/images/powered_by.png'; + // Optional, an actual size of thumbnail to enable lazy loading + $obj->thumb_width = 200; + $obj->thumb_height = 44; + $results[] = $obj; return $results; } else { @@ -553,12 +561,16 @@ class FtpAdapter implements AdapterInterface $obj->modified_date = $obj->create_date; $obj->modified_date_formatted = $obj->create_date_formatted; $obj->mime_type = $file['type'] == 'file' ? $this->extension_mime_mapper(strrchr($file['name'], ".")) : "directory"; - if ($obj->mime_type == 'image/png' || $obj->mime_type == 'image/jpeg') { - $obj->thumb_path = Uri::root() . "images/powered_by.png"; - } $obj->width = 0; $obj->height = 0; + // Add thumbnail preview when possible. Recomended size: should fit in to 200x200px box. + // Relative or full path. + $obj->thumb_path = Uri::root(true) . '/images/powered_by.png'; + // Optional, an actual size of thumbnail to enable lazy loading + $obj->thumb_width = 200; + $obj->thumb_height = 44; + $results[] = $obj; } return $results; @@ -938,4 +950,4 @@ class FtpAdapter implements AdapterInterface return $nameWithoutExtension . $extension; } } -``` \ No newline at end of file +``` diff --git a/migrations/52-53/new-features.md b/migrations/52-53/new-features.md index 0c81a09b..e584f5ce 100644 --- a/migrations/52-53/new-features.md +++ b/migrations/52-53/new-features.md @@ -65,3 +65,9 @@ public function onInstallerBeforeUpdateSiteDownload(\Joomla\CMS\Event\Installer\ $event->updateUrl($event->getUrl() . '?auth=foo'); } ``` + +#### Media: allow thumbnail for any file type + +The changes allow to add thumbnail for any file type: video, pdf, audio etc. Previously it was worked only for images. + +PR: https://github.com/joomla/joomla-cms/pull/44847