Scottnj
05/10/2023, 4:21 PMMedias::make()->name('main-image')
to a component block it creates the form field.
I am able to select an image in the backend UI, but I cannot figure out how to get it to render for the frontend.Scottnj
05/10/2023, 4:21 PMphp artisan twill:make:componentBlock image
Scottnj
05/10/2023, 4:21 PMuse A17\Twill\Services\Forms\Fields\Input;
use A17\Twill\Services\Forms\Fields\Medias;
use A17\Twill\Services\Forms\Form;
use A17\Twill\View\Components\Blocks\TwillBlockComponent;
use Illuminate\Contracts\View\View;
class Image extends TwillBlockComponent
{
public function render(): View
{
return view('components.twill.blocks.image');
}
public function getForm(): Form
{
return Form::make([
Input::make()->name('title'),
Medias::make()->name('main-image')
]);
}
}
Scottnj
05/10/2023, 4:22 PM@if($block->hasImage('main-image'))
<img src="{{ $block->image('main-image') }}" alt="{{ $block->imageAltText('main-image') }}" />
@else
<p>Image not found</p>
<pre>
{{ dd($block->image('main-image')) }}
</pre>
@endif
Scottnj
05/10/2023, 4:22 PMImage not found
"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" // resources/views/components/twill/blocks/image.blade.php
ifox
05/10/2023, 5:26 PM$block->image('main-image', 'crop-key')
Scottnj
05/10/2023, 6:37 PM