Skip to content

Conversation

@zeezo887
Copy link
Collaborator

Description

This PR allows support for adding media in JSON repeaters. Media items for json repeaters are now saved in the mediables table role column in {$repeatedName}|{$repeaterIndex}|{$role} format.
Also added a helper method to easily get the role for a JSON repeater.

if (! function_exists('getJsonRepeaterMediaRole')) {
    function getJsonRepeaterMediaRole($role, $repeaterName, $index): string
    {
        return "$repeaterName|$index|$role";
    }
}

If you have a JSON repeater with medias named features, you can display the image like so:

@foreach($item->features as $index => $feature)
    <img src="{{ $item->image(getJsonRepeaterMediaRole($role, 'features', $index), 'mobile') }}">
@endforeach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants