Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for medias in json repeaters #2554

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from

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.

None yet

1 participant