Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Only fetch the width and height when it is a file #116

Merged
merged 3 commits into from
Mar 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -277,20 +277,16 @@ private function getPathInformation($path)
$obj->modified_date = $modifiedDate->format('c', true);
$obj->modified_date_formatted = (string) $modifiedDate; // TODO use format from config
$obj->mime_type = mime_content_type($path);
$obj->width = 0;
$obj->height = 0;

try
if (strpos($obj->mime_type, 'image/') === 0 && in_array(strtolower($obj->extension), array('jpg', 'jpeg', 'png', 'gif', 'bmp')))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we put this in an isImage method to be more readable?

{
// Get the image properties
$props = JImage::getImageFileProperties($path);
$obj->width = $props->width;
$obj->height = $props->height;
}
catch (Exception $e)
Copy link
Contributor

Choose a reason for hiding this comment

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

What kind of exception do we catch here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'v removed that and opened issue #117 as we don't have a defined way of exception handling.

{
// Probably not an image
$obj->width = 0;
$obj->height = 0;
}

return $obj;
}
Expand All @@ -310,7 +306,7 @@ private function getDate($date = null)

$timezone = JFactory::getApplication()->get('offset');
$user = JFactory::getUser();

if ($user->id)
{
$userTimezone = $user->getParam('timezone');
Expand Down