Skip to content

Commit e61dd7e

Browse files
committed
Use a view so it can be overridden
1 parent 47f53fa commit e61dd7e

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

Readme.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ will output as:
4040

4141
`<img src="data:image/png;base64,iVBOR…8f8luO3RPLKe4AAAAAElFTkSuQmCC" width="640" height="640" onload="console.log('loaded')" />`
4242

43+
If you want to override the output, you can publish the view to your own views folder by running:
44+
45+
```
46+
php artisan vendor:publish --tag="statamic-blurhash"
47+
```
48+
49+
it will then be found at `resources/views/vendor/statamic-blurhash/output.blade.php`
50+
4351

4452
### Encoding a BlurHash image
4553

resources/views/output.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<img src="{{ $src }}" {!! $params !!} />

src/ServiceProvider.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,11 @@ class ServiceProvider extends AddonServiceProvider
99
protected $tags = [
1010
Tags\BlurHash::class,
1111
];
12+
13+
public function bootAddon()
14+
{
15+
$this->publishes([
16+
__DIR__.'/../resources/views' => base_path('resources/views/vendor/statamic-blurhash'),
17+
], 'statamic-blurhash');
18+
}
1219
}

src/Tags/BlurHash.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ public function decode($encodedString = null)
5555
public function index()
5656
{
5757
$image = $this->params->get('image');
58-
59-
return '<img src="'.$this->decode($this->encode($image)).'" '.$this->renderAttributesFromParams(['image']).' />';
58+
59+
return view('statamic-blurhash::output', [
60+
'src' => $this->decode($this->encode($image)),
61+
'params' => $this->renderAttributesFromParams(['image']),
62+
]);
6063
}
6164

6265
/**

0 commit comments

Comments
 (0)