Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Media: allow thumbnail for any file type #44847

Open
wants to merge 2 commits into
base: 5.3-dev
Choose a base branch
from

Conversation

Fedik
Copy link
Member

@Fedik Fedik commented Feb 9, 2025

Summary of Changes

The changes allows thumbnail for any file type: video, pdf, audio etc.

Testing Instructions

Apply path, run npm install.
Edit

if (!$isDir && MediaHelper::isImage($obj->name)) {

And add following else condition (optionaly change the image path):

else {
  if (!$isDir){
    $obj->thumb_path = Uri::root(true) . '/images/headers/raindrops.jpg';
  } else {  
    $obj->thumb_path = Uri::root(true) . '/images/headers/maple.jpg';
  }
}

Go to media manager and upload some video, or audio or any other file.
Thn check the thumbnail.

Actual result BEFORE applying this Pull Request

Non image files has a icon

Expected result AFTER applying this Pull Request

Non image files has a 'raindrops.jpg' image

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:
  • No documentation changes for docs.joomla.org needed
  • Pull Request link for manual.joomla.org: TBD
  • No documentation changes for manual.joomla.org needed

@joomla-cms-bot joomla-cms-bot added NPM Resource Changed This Pull Request can't be tested by Patchtester PR-5.3-dev labels Feb 9, 2025
@Fedik Fedik added the Feature label Feb 9, 2025
@brianteeman
Copy link
Contributor

Maybe I am missing something but I am missing the usecase for this and how it can be used by a siteowner without core hacks

@Fedik
Copy link
Member Author

Fedik commented Feb 10, 2025

No need core hacks, what you see in the description is for testing only.

The use case:

  • 3rd filesystem plugins could add thumbnail for their files (I curently need it for video thumbnail for personal project)
  • 3rd plugin could add thumbnail to existing files while listening onFetchMediaItems :
public function onFetchMediaItems($event)
{
  $items = $event->getArgument('items');

  foreach ($items as $item) {
    if (in_array($item->extension, ['mp4', 'mp3', 'pdf'])) {
      $item->thumb_path = Uri::root(true) . '/images/headers/raindrops.jpg';  
    }
  }

  $event->setArgument('items', $items);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature NPM Resource Changed This Pull Request can't be tested by Patchtester PR-5.3-dev
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants