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

Add Mediafinder dimensions #958

Draft
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

AIC-BV
Copy link
Contributor

@AIC-BV AIC-BV commented Aug 3, 2023

This PR adds the dimensions to an image in the Mediafinder
image

Comment on lines +643 to +648
if ($itemType === MediaLibraryItem::TYPE_FILE) {
$imageDimensions = getimagesize($this->getStorageDisk()->path($item['path']));
$dimensions = "$imageDimensions[0] x $imageDimensions[1]";
} else {
$dimensions = null;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TYPE_FILE would also include videos, audio, etc.

It this could be limited by only applying this logic to $item->getFileType() === MediaLibraryItem::FILE_TYPE_IMAGE, however that will not be available until after the MediaLibraryItem has been inited.

* @param int $size
* @param int $lastModified
* @param string $type
* @param string $publicUrl
*/
public function __construct($path, $size, $lastModified, $type, $publicUrl)
public function __construct($path, $dimensions, $size, $lastModified, $type, $publicUrl)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be passing this as the last argument for maximum BC, and since it's only relevant to specific types of media items we should start moving towards metadata support, so the parameter should actually be array $metadata and contain 'dimensions' as a an array with 'width' and 'height' values.

* folders dimensions is always NULL.
*/
if ($itemType === MediaLibraryItem::TYPE_FILE) {
$imageDimensions = getimagesize($this->getStorageDisk()->path($item['path']));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work for files stored on disks that aren't the local disk.

Copy link

github-actions bot commented Feb 6, 2024

This pull request will be closed and archived in 3 days, as there has been no activity in this pull request for the last 6 months.
If you intend to continue working on this pull request, please respond within 3 days.
If this pull request is critical for your business, please reach out to us at [email protected].

@github-actions github-actions bot added the stale Issues/PRs that have had no activity and may be archived label Feb 6, 2024
@bennothommo bennothommo added enhancement PRs that implement a new feature or substantial change Status: In Progress and removed stale Issues/PRs that have had no activity and may be archived labels Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement PRs that implement a new feature or substantial change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants