• Resolved Matt

    (@syntax53)


    Can’t seem to find a good example of how to use this. I am showing a random single image from a range of nested Att. Categories. I would to include in the markup either A) The name of the category in which the image was pulled from, B) the title of the page that the image is inserted in or C) the permalink of the page that the image is inserted in. Any one of those 3 would be fine. In the case of option C I’d like to make the link of the image point to that permalink.

    [mla_gallery attachment_category="art-exhibits" size="thumbnail" link="full" orderby="rand" numberposts="1" mla_float="none" mla_margin="auto" mla_itemwidth="90%"]

    I see the “Field-level data sources” in the documentation but I can’t get a clear understanding of how to implement.

    Thanks

    https://www.ads-software.com/plugins/media-library-assistant/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author David Lingren

    (@dglingren)

    Thanks for your question; I want to make sure I understand the details of your application.

    You wrote “the page that the image is inserted in” – do you mean the page in which the [mla_gallery] shortcode appears or some other page where the image is inserted in the page content? That will determine the answer to your alternatives B) and C).

    There are a few ways to display “ A) The name of the category in which the image was pulled from“. First, you can add something like mla_caption="{+terms:attachment_category+}" to display the category name(s) of the terms assigned to the item. If there are multiple terms you will see all of them. Second, you can mla_caption="{+request:attachment_category+}" to display the category slug you entered in the shortcode. Finally, you could add a parameter of your own, such as my_category_title="Art Exhibits" to the shortcode and then use mla_caption="{+request:my_category_title+}" to display it.

    I am using mla_caption as a easy way to experiment with different alternatives. If you already have captions you can use something like mla_caption="{+caption+}<br>{+terms:attachment_category+}" to show both. Of course, you can define a custom markup template to get even more control over the gallery layout and content.

    For your alternative B) you can try mla_caption="{+parent_title+}" or mla_caption="{+inserted_in_title+}" depending on what you mean by “the page that the image is inserted in“.

    I hope that gets you started on using field-level data sources for your [mla_gallery] content. I will leave this topic unresolved until I hear back from you with any problems or additional questions you have. Thanks for your interest in the plugin.

    Thread Starter Matt

    (@syntax53)

    Thank you for the reply and I believe that answers my question fully for options A and B. As for C, I was referring to the page the image is inserted in, which is different from the page where that shortcode appears.

    Thanks

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update and the clarification regarding “inserted in”.

    There is no specific support in the current MLA version for accessing “the permalink of the page that the image is inserted in“. There is, however, an example plugin that could be adapted to your application. Have a look at this earlier support topic:

    Media Library Modal – Show Featured/Inserted In

    Your application is somewhat simpler; you may not need the ACF fields and the custom table views. What you need is a custom field that contains the permalink of the “inserted in” post/page. You could then use that field in your [mla_gallery] by coding something like {+custom:Inserted in Permalink+}.

    If you are interested in adapting that example to your application, let me know.

    Thread Starter Matt

    (@syntax53)

    No that’s fine. I’ll go with options A and/or B. Thanks for the support.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Help with Field-level data sources markup’ is closed to new replies.