How to display image from InlineRepeater

I want to dispaly the image from InlineRepeater. Please help me how to do it.
33 Replies
HealMan
HealManOP9mo ago
Hi, @ifox , Please look at this.
HealMan
HealManOP9mo ago
I want to display this image in blade. How to do this?
No description
HealMan
HealManOP9mo ago
<img src="{{ $feature['medias']['image'][0]['original'] }}" /> I can display using this but is there another way?
ifox
ifox9mo ago
$feature->image('image', 'your_crop_name', ['w' => 1000]) w => 1000 is just an example
HealMan
HealManOP9mo ago
w is sth like index?
ifox
ifox9mo ago
It's width you can pass any param supported by Glide
ifox
ifox9mo ago
Quick reference - Glide
Wonderfully easy on-demand image manipulation library with an HTTP based API.
HealMan
HealManOP9mo ago
well...
No description
HealMan
HealManOP9mo ago
$feature is one of features...
HealMan
HealManOP9mo ago
No description
ifox
ifox9mo ago
How are you saving this repeater? Using a Feature model? Or a JSON column? JSON repeaters do not support medias fields at the moment
HealMan
HealManOP9mo ago
I don't think we are using Feature model.
ifox
ifox9mo ago
What do you have in the repository class of the module where you are using this inline repeater field?
HealMan
HealManOP9mo ago
No description
ifox
ifox9mo ago
Ok, so JSON repeater. You cannot use medias fields when saving a repeater using $jsonRepeaters. You should use $repeaters in the repository, a features hasMany relationship in your Location model, pointing to a Feature model which uses HasMedias. That way you can use ->image like I said above. OR, if you don't want to deal with any of that, use a features block in a block_editor field. You won't have to create another model and deal with migrations etc...
HealMan
HealManOP9mo ago
I see.
ifox
ifox9mo ago
A lot of users are trying to use medias fields in JSON repeaters though, and we are going to look into it. Just so you know, the reason it is not supported is because we do not want to store a media reference in a model JSON column, we want all media references to be stored in the mediables table so we can know exactly where a specific image is being used in the content. I have an idea in mind to do that though, so we'll look into it.
HealMan
HealManOP9mo ago
Great! And I have a problem with storing images.
HealMan
HealManOP9mo ago
No description
No description
HealMan
HealManOP9mo ago
it shows that content saved but after refresh, image is blank.
ifox
ifox9mo ago
Yes, because JSON repeaters do not store attached medias. If you save it using an actual relationship it would work.
HealMan
HealManOP9mo ago
well... then what about this? when I name the medias as 'hightlight' it shows the saved content but when I change name to anything like 'image' or 'images', it doesn't show the saved content.
No description
HealMan
HealManOP9mo ago
And this is block... I used this block inside of another model using Block Editor.
ifox
ifox9mo ago
If you change the name after saving, that's expected. If not, it could be a conflict with other crop configurations in your project, but that shouldn't prevent saving and retrieving it.
HealMan
HealManOP9mo ago
well.. I only configured crop in twill.php.
HealMan
HealManOP9mo ago
inside of crops... I have 'highlight', is this something prevent me to name medias input other than 'highlight'?
No description
ifox
ifox9mo ago
no, it doesn't prevent it, but if you want to use something other than highlight, you should also define a key for that in the crops array There is a default crop configuration if you use 'image' as the crop name, but most likely you need to apply your own configuration
HealMan
HealManOP9mo ago
so if we have 3 different Medias Name? then I should have 3 itmes in crops array?
ifox
ifox9mo ago
yes, exactly. but you can reuse the same medias name across multiple blocks
HealMan
HealManOP9mo ago
That makes sense. Thank you very much for your help. So regarding features repeater, I need to create feature block and use it in location. And do I need to use Block Editor? or is there other way that I can use feature block without Block Editor?
ifox
ifox9mo ago
Yeah blocks are used within the block editor field. The only difference really with a repeater from a UX perspective is that if your block editor has a single possible block, the user needs to click twice instead of once to add an item (first on the add button then on the name of the block in the list). but like I said, we are looking into supporting medias fields in the repeater json column approach.
HealMan
HealManOP9mo ago
Okay, Sounds great! So right now to use feature block, I have to create a new block. And I have to insert Block Editor to Location. Block Editor can add any block but how can I make Feature Block only available for that Block Editor?
ifox
ifox9mo ago
'blocks' => [FeatureBlock::class] on the block editor field
Want results from more Discord servers?
Add your server