Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Tam committed Apr 28, 2020
2 parents ec50d45 + 39f013d commit c38f3d1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.7 - 2020-04-28
### Improved
- Remote assets will now cache their calculated dimensions

## 1.0.6 - 2020-04-28
### Added
- Add `title` option to picture helper
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ether/thumbro",
"description": "Craft CMS image transformations powered by Thumbor",
"version": "1.0.6",
"version": "1.0.7",
"type": "craft-plugin",
"license": "proprietary",
"minimum-stability": "dev",
Expand Down
12 changes: 11 additions & 1 deletion src/RemoteAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace ether\thumbro;

use Craft;

/**
* Class RemoteAsset
*
Expand All @@ -26,9 +28,17 @@ class RemoteAsset

public function __construct ($url, $title = '')
{
$cache = Craft::$app->getCache();
$key = 'thumbro_size_cache_' . urlencode($url);

$this->url = $url;
$this->title = $title;
$size = getimagesize($url);
if ($cache->exists($key)) {
$size = $cache->get($key);
} else {
$size = getimagesize($url);
$cache->set($key, $size);
}
$this->width = $size[0];
$this->height = $size[1];
$this->extension = [
Expand Down

0 comments on commit c38f3d1

Please sign in to comment.