Skip to content

Commit

Permalink
update usage example
Browse files Browse the repository at this point in the history
  • Loading branch information
Gummibeer committed Mar 2, 2020
1 parent 45d345c commit 1cf63cc
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ php artisan vendor:publish --provider="Astrotomic\Weserv\Images\Laravel\WeservIm
```php
use Astrotomic\Weserv\Images\Enums\Fit;

echo weserv('https://example.com/image.jpg')->w(512)->h(512)->we()->fit(Fit::INSIDE);
echo weserv('https://images.weserv.nl/lichtenstein.jpg')->w(512)->h(512)->we()->fit(Fit::INSIDE);
// https://images.weserv.nl/?w=512&h=512&we=1&fit=inside&url=https%3A%2F%2Fimages.weserv.nl%2Flichtenstein.jpg
```

Expand All @@ -42,8 +42,9 @@ The following example will create a `<picture>` tag with a `webp` source and a `

```php
use Astrotomic\Weserv\Images\Laravel\Url;
use Astrotomic\Weserv\Images\Enums\Fit;

echo weserv('https://example.com/image.jpg')->toPicture([
echo weserv('https://images.weserv.nl/lichtenstein.jpg')->w(512)->h(512)->we()->fit(Fit::INSIDE)->toPicture([
'alt' => 'The alt text for this image',
'class' => 'rounded',
'loading' => 'lazy',
Expand All @@ -53,6 +54,18 @@ echo weserv('https://example.com/image.jpg')->toPicture([
]);
```

```html
<picture>
<source type="image/webp" src="https://images.weserv.nl?w=512&h=512&we=1&fit=inside&output=webp&url=https%3A%2F%2Fimages.weserv.nl%2Flichtenstein.jpg" srcset="https://images.weserv.nl?w=512&h=512&we=1&fit=inside&output=webp&dpr=1&url=https%3A%2F%2Fimages.weserv.nl%2Flichtenstein.jpg 1x, https://images.weserv.nl?w=512&h=512&we=1&fit=inside&output=webp&dpr=2&url=https%3A%2F%2Fimages.weserv.nl%2Flichtenstein.jpg 2x" />
<img alt="The alt text for this image" class="rounded" loading="lazy" src="https://images.weserv.nl?w=512&h=512&we=1&fit=inside&url=https%3A%2F%2Fimages.weserv.nl%2Flichtenstein.jpg" srcset="https://images.weserv.nl?w=512&h=512&we=1&fit=inside&dpr=1&url=https%3A%2F%2Fimages.weserv.nl%2Flichtenstein.jpg 1x, https://images.weserv.nl?w=512&h=512&we=1&fit=inside&dpr=2&url=https%3A%2F%2Fimages.weserv.nl%2Flichtenstein.jpg 2x" />
</picture>
```

<picture>
<source type="image/webp" src="https://images.weserv.nl?w=512&h=512&we=1&fit=inside&output=webp&url=https%3A%2F%2Fimages.weserv.nl%2Flichtenstein.jpg" srcset="https://images.weserv.nl?w=512&h=512&we=1&fit=inside&output=webp&dpr=1&url=https%3A%2F%2Fimages.weserv.nl%2Flichtenstein.jpg 1x, https://images.weserv.nl?w=512&h=512&we=1&fit=inside&output=webp&dpr=2&url=https%3A%2F%2Fimages.weserv.nl%2Flichtenstein.jpg 2x" />
<img alt="The alt text for this image" class="rounded" loading="lazy" src="https://images.weserv.nl?w=512&h=512&we=1&fit=inside&url=https%3A%2F%2Fimages.weserv.nl%2Flichtenstein.jpg" srcset="https://images.weserv.nl?w=512&h=512&we=1&fit=inside&dpr=1&url=https%3A%2F%2Fimages.weserv.nl%2Flichtenstein.jpg 1x, https://images.weserv.nl?w=512&h=512&we=1&fit=inside&dpr=2&url=https%3A%2F%2Fimages.weserv.nl%2Flichtenstein.jpg 2x" />
</picture>

### Testing

``` bash
Expand Down

0 comments on commit 1cf63cc

Please sign in to comment.