One random image from an Image Advanced field in Oxygen

Support General One random image from an Image Advanced field in Oxygen

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #29468
    IlanIlan
    Participant

    I'm trying to accomplish exactly what this guy is doing here
    https://www.youtube.com/watch?v=9MlhGtdKBj4
    but using metabox instead of ACF.
    He is using this snippet
    https://www.paulchinmoy.com/display-random-image-acf-gallery-oxygen-builder/

    I'm sure a view with Twig is probably the right direction, but I'm not sure. Do you have any suggestions?
    The other factor is the field is saved in a Settings page, not at the post level, if that matters.

    #29478
    Long NguyenLong Nguyen
    Moderator

    Hi ilan,

    Thank you for reaching out.

    Meta Box has the same way to create image_advanced field and get its value. You can get more details on the documentation
    https://docs.metabox.io/fields/image-advanced/
    https://docs.metabox.io/extensions/mb-settings-page/

    Paul uses the PHP code to create the snippet so I think you should also use PHP code to understand how it works.

    #29483
    IlanIlan
    Participant

    Ya it looks like this one is above my head. I'll have to hope someone makes a video tutorial for me one day 🙂

    #29577
    IlanIlan
    Participant

    Ya I'm totally lost here - can you help me out please? What changes would I make to the snippet to have it work with metabox and pulling images from the settings page fields?

    #29578
    IlanIlan
    Participant

    I think I'm getting closer - using MB Views I'm trying to output a random item from the array.

    {% set group = attribute( site, 'practice-specific-images' ) %}
    {% set item = random(group) %}
        <img src="{{ item.full.url }}" width="100%" height="auto" alt=""> 
     

    unfortunately this is not giving me anything on the front end, viewing the source give me "unknown" for the URL.
    Saved as a shortcode for easy use in Oxygen.
    I feel like i'm so close here - any suggestions you can offer?

    #29580
    IlanIlan
    Participant

    FINALLY GOT IT!

    For the next person with this problem, i got there in the end using views, just forgot to add the field name to the random function

    {% set group = attribute( site, 'practice-specific-images' ) %}
    {% set item = random(group.gallery) %}
        <img src="{{ item.full.url }}" width="100%" height="auto" alt=""> 

    `

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.