Support » Plugin: Media Library Assistant » Filter tag cloud to tags on current post?

  • Resolved lastqa

    (@lastqa)


    Is it possible to filter the tag_cloud (or term_list) to only include att_tags associated with attachments on a current post? I want to include a taxonomy similar to the built in function of showing post tags but to show tags for any of the attachments on the current post. I’ve got the destination gallery page set up from code in other articles and the displayed tag cloud redirecting to it, just want to show only tags relevant to the current post.

    I know I can set specific term IDs but I want to add this into the post display template so that it’s dynamic and only shows the half dozen tags on those attachments and not he 200+ across all posts (or more frequent that don’t even appear on this one).

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

    (@dglingren)

    Thanks for an interesting question. I want to make sure I understand what you mean by “attachments on a current post” and “tags relevant to the current post“.

    How are the attachments related to the post, i.e., are they “attached” to the post in the WordPress sense, do they appear in an [mla_gallery] in the post content, are they inserted in the post content or are they related in some other way?

    Any additional details you can provide will be helpful. Thanks for your interest in the plugin.

    Thread Starter lastqa

    (@lastqa)

    They could be attached in the WordPress point of view of having been uploaded directly to the post but my original thought was anything (images for me) shown on the post either inline, default gallery or cover blocks, (not really sure about the technical difference or value other than media library showing “parent”) third party galleries would be ideal (formatting options they offer) but understand some work very differently and could cause issues. for most of these posts I’m not sure how I could use [mla_gallery] as the original gallery in the post.

    Example would be a post for a Halloween party, the post has it’s own “event” category and “Halloween, costume, party” tags that show in normal wordpress taxonomies and can be clicked to view archives of posts sharing those tags. I want to add a taxonomy for the individual images that have att_tags like “vampire, nurse, zombie”. I want people to be able to see and click “vampire” to go to my new ‘att_archive_page’ to see all my images with the tag “vampire”.

    Similarly a post with a broader “landscape” category or tag would have individual images that are more tightly identified by “sunset, lake, coast, mountains” but “vampire” definitely shouldn’t appear on this post.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your response with the additional information about your application ideas.

    You wrote “my original thought was anything (images for me) shown on the post“. That is a complex requirementbeyond the capabilities of the current MLA version. Each of the examples you outlined requires a different method of finding the Media Library items it includes:

    • The Gutenberg Image and Gallery blocks and the earlier WordPress “Insert media” features simply embed an image reference and some other information on the body of the post/page. Tools like the MLA Insert Fixit example plugin extract URLs and attachment IDs by pattern matching within the content.
    • Shortcodes like [mla_gallery] and the WordPress [gallery] (used by many other plugins as well) must be extracted from post content and executed to determine what items they display in their gallery output. The output must often be pattern matched to extract attachment IDs, and the patterns differ from plugin to plugin.
    • Page builders and third-party galleries must be analyzed one by one to determine the bast way to identify attachment IDs.

    The [mla_gallery] shortcode provides many “hooks”, actions and filters, that could be used to derive attachment IDs and other information without pattern matching the shortcode output. Other themes and plugins vary widely in this regard as well. You wrote “I’m not sure how I could use [mla_gallery]“. You can find several examples in the Settings/Media Library Assistant Documentation tab and many of the earlier topics in this forum have more elaborate applications of the shortcode.

    In summary, your application idea is a good one and a candidate for a custom plugin tailored to the specifics of your site’s theme, plugins and coding practices. I regret that the help I can provide would be limited to answering questions about how MLA works.

    You wrote “I want people to be able to see and click “vampire” to go to my new ‘att_archive_page’ to see all my images with the tag “vampire”. It looks like you have developed a WordPress template (PHP) file for the attachments archive, so you may be interested in this earlier topic:

    Custom Post Type Mapping with MLA

    That topic says more about attachment archives and some MLA example plugins to help identify Media Library items embedded in the post content. An earlier post in that topic describes how the [mla_gallery] shortcode can be used for taxonomy-related galleries.

    I am marking this topic resolved simply because your question has been answered to the best of my ability. I wish you every success with your application and would be happy to address any MLA-specific questions or problems in a new topic or an update to this topic. `Thanks for your response with the additional information about your application ideas. Thanks for your understanding.

    Thread Starter lastqa

    (@lastqa)

    I don’t know if I explained wrong or am reading wrong? This seem like a yes and no, I’m by no means a developer and for vision difficulties never can be since screen time (especially reading) is extremely limited.

    The above tells me that if I have a post where

    [mla_gallery]
    size=thumbnail
    [/mla_gallery]

    works (not ideal to be used on every post since I want/need a visual gallery editor but very powerful for other pages) my understanding is I have what this plugin needs to do what I want.

    the tag cloud I have now is

    [mla_tag_cloud]
    taxonomy=attachment_tag post_mime_type=image
    mla_link_href="/images-by-tags/?current_id={+term_id+}"
    number=20
    smallest=8 largest=20 
    separator=' - '
    include="321. 324"
    [/mla_tag_cloud]

    I just don’t know the coding to make include=”1, 2, 3″ into include=on-this-post so that I don’t have to manually lookup and add the (randomly generated?) tag IDs on every post. I want something that pulls automatically and can then be added as a reusable block the same way post taxonomies are.

    my destination page is just a page, no template or php, just has three shortcodes copied out to display the [mla-gallery], pagination, and a full [mla_tag_cloud]

    Maybe it’s still out of scope, just trying to make sure I’m clear since I can’t imagine I’m the first person trying to do this (or everything else on wordpress I can’t find answers for)

    • This reply was modified 3 months, 2 weeks ago by lastqa.
    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update with the additional comments and the shortcode text. It looks like you have made quite a bit of progress understanding and applying MLA shortcodes!

    You wrote “I can’t imagine I’m the first person trying to do this“. Not exactly, but you are the first to ask for such a general solution. Here is an earlier topic asking for a more specific solution:

    Need help

    In that topic the “include” criterion was simple – all items assigned to a particular attachment_category term.

    As I described in my previous post, a solution for include=on-this-post has two parts. The first part is “find all the Media Library items on this post”; that’s the hard part. The second part, “find the terms assigned to the items”, is easy once the items are known. The [mla_tag_cloud] has an ids= parameter that does the job.

    You wrote “I want/need a visual gallery editor“. If you can use the WordPress Gutenberg Image and Gallery blocks it would be straightforward to develop a bit of code to find the items they contain. These blocks have a static set of items and their ID values are embedded in the HTML code of the post content.

    Other visual gallery editors use different ways to store their gallery items, e.g., a different encoding in the post content or simply storing a gallery ID in the post content that refers to some other location such as a custom database table.

    An answer that works for your site depends on the gallery editor(s) you choose; there is no general solution. Once you pick your editor I would be happy to investigate the work required to give you a specific solution. I would implement it as an MLA example plugin and make it available to you and other MLA users.

    Thread Starter lastqa

    (@lastqa)

    For the gallery editor then I’m content with the built-in Gutenberg block gallery for this purpose. I do use the “spectra” plugin which ads a masonry layout and would love to find a mosaic layout that works (photonic mla_gallery doesn’t work due to constant re-randomization) but will sacrifice layouts if necessary, just trying to keep everything as simple as possible and show the gallery in the post as I want but would like to also include links to image/aka att_tags similarly to post-tags.

    I’m using the default gallery because I can upload images directly to the post and they appear as “attached” and I can then view and add meta details in media library. It’s extremely frustrating having to turn off “crop” and re-assign columns and image size with every post but this seems to be a global wordpress failing. the mla_gallery works on the same post but then becomes redundant and requires additional coding so no reason to remove the original and then try to organize the mla_gallery.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update with the design choices. You mentioned “Spectra”, which I assume refers to this plugin:

    Spectra – WordPress Gutenberg Blocks
    By Brainstorm Force

    I installed a copy on my system and set up a post with Spectra Image and Masonry Gallery blocks. As they promise, their blocks use the same structure WordPress does to identify the items in the block.

    I will work on an example plugin along the lines you need for your application and post an update here when I have progress to report. Thanks for your patience and understanding.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your patience while I worked on an example plugin for your application. I have completed an initial version that finds items inserted in the page/post content using Gutenberg Image and Gallery blocks as well as the Spectra Image and Masonry Gallery blocks.

    I have uploaded a new MLA Development Version dated 20221101 that contains the new plugin. You can find step-by-step instructions for using the Development Version in this earlier topic:

    PHP Warning on media upload with Polylang

    Once the Development Version is installed you must install and activate the example plugin. Navigate to the Settings/Media library Assistant Documentation tab and click the “Example Plugins” button. Type “content” in the text box and click “Search Plugins” to filter the table.

    You are looking for the “MLA Content Items Example” plugin. Find that plugin and hover over the title in the left-most column. Click the “Install” rollover action, then go to the WordPress Plugins/Installed Plugins submenu and activate the example plugin as you would any other plugin.

    Once the Development Version and example plugin are installed and active you can update your [mla_tag_cloud] shortcode to use the new parameter:

    [mla_tag_cloud]
    taxonomy=attachment_tag post_mime_type=image
    mla_link_href="/images-by-tags/?current_id={+term_id+}"
    number=20
    smallest=8 largest=20 
    separator=' - '
    ids="{+content_items+}"
    [/mla_tag_cloud]
    

    The only change is replacing your original include="321. 324" parameter with ids="{+content_items+}".

    This example plugin will be part of my next MLA version, but in the interim it would be great if you could install the Development Version and the example plugin and let me know if it works for you. Thanks for inspiring this MLA improvement.

    Thread Starter lastqa

    (@lastqa)

    This looks likes it’s working! Thank you so much for your help, I’ve been beating my head against the desk on this since the first time I touched wordpress.

    My only thought to extend usability for others might be to extend functionality to work on [mla_gallery] as well but seems to be working perfect for built in gallery.

    Thanks again!

    Plugin Author David Lingren

    (@dglingren)

    Thanks for confirming that the new substitution parameter is working for you, and for your [mla_gallery] suggestion. I will look at adding other features like that to the example plugin as I have time.

    Thanks as well for your generous and positive MLA review. Positive feedback and good reviews are an incentive to keep working on the plugin and supporting its users.

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