Skip to content

Commit

Permalink
Update to 5.5.
Browse files Browse the repository at this point in the history
Add support AVIF image format (requires PHP 8.1.0)
  • Loading branch information
denysdesign committed Nov 21, 2022
1 parent ea7740b commit 5306d82
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,41 @@ $thumb = $juImg->render('images/sampledata/fruitshop/apple.jpg', [
|--------------|---------|---------|----------------------------------------------------------------------------------------|
| webp | Boolean | false | If `true` add support WebP image. For this option use tag `<picture>`, see in example. |

### AVIF support

AVIF image format (requires PHP 8.1.0)

```php
<?php

$thumb = $juImg->render('images/sampledata/fruitshop/apple.jpg', [
'w' => '300',
'h' => '100',
'q' => '95',
'avif' => true
]);
?>

<picture>
<source srcset="<?php echo $thumb->avif; ?>" type="image/avif">
<img src="<?php echo $thumb->img; ?>" alt="Apple" width="300" height="100">
</picture>
```

Display as:

```html

<picture>
<source srcset="img/apple.jpg.avif" type="image/avif">
<img src="img/apple.jpg" alt="Apple" width="300" height="100">
</picture>
```

| WebP command | Type | Default | Description |
|--------------|---------|---------|-------------------------------------------------------------------------|
| avif | Boolean | false | If `true` add support WebP image. For this option use tag `<picture>`. AVIF image format (requires PHP 8.1.0) |

### YouTube and Vimeo support

Youtube:
Expand Down
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
basedir=".">

<property name="VERSION"
value="5.4" />
value="5.5" />
<property name="build"
value="build" />
<property name="temp"
Expand Down
8 changes: 8 additions & 0 deletions src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ public function render($url, array $attr = [])
];
}

if(isset($attr[ 'avif' ]) === true)
{
return (object) [
'img' => $img,
'avif' => $this->thumb($url, array_merge($attr, [ 'f' => 'avif' ]))
];
}

return $img;
}

Expand Down

0 comments on commit 5306d82

Please sign in to comment.