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

Merged
merged 2 commits into from
May 28, 2024

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

@ifox ifox merged commit d2cb855 into area17:3.x May 28, 2024
11 checks passed
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