Skip to content

Commit

Permalink
Add title option to picture helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Tam committed Apr 28, 2020
1 parent 7dc09b7 commit 0dcd896
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 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.6 - 2020-04-28
### Added
- Add `title` option to picture helper

## 1.0.5 - 2020-04-28
### Fixed
- Remote assets now store mimetype correcty
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ setting it to `true`.

#### Config Options

In addition to the regular transform config options, `picture` has two unique
options:
In addition to the regular transform config options, `picture` has additional
unique options:

**`noJs`** [bool]

Expand All @@ -117,6 +117,10 @@ Will disable the automatic injection of the lazy loading JavaScript.
Will convert the lazy loading to eager loading when true, meaning the image will
instantly load in most cases.

**`title`** [bool]

The title that will be output in the image tag.


#### JS

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.5",
"version": "1.0.6",
"type": "craft-plugin",
"license": "proprietary",
"minimum-stability": "dev",
Expand Down
4 changes: 3 additions & 1 deletion src/RemoteAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ class RemoteAsset
public $height;
public $extension;
public $mimeType;
public $title;

public function __construct ($url)
public function __construct ($url, $title = '')
{
$this->url = $url;
$this->title = $title;
$size = getimagesize($url);
$this->width = $size[0];
$this->height = $size[1];
Expand Down
2 changes: 2 additions & 0 deletions src/Variable.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public function picture ($asset, array $transform, array $config = [])
if (is_string($asset))
$asset = new RemoteAsset($asset);

$asset->title = @$config['title'] ?? $asset->title;

if (!ArrayHelper::isAssociative($transform, true))
throw new Exception('The `picture` method only supports a single transform!');

Expand Down

0 comments on commit 0dcd896

Please sign in to comment.