Support » Plugin: Media Library Assistant » Att. Tags on attachment page

  • Resolved ratamatcat

    (@ratamatcat)


    Hello again,

    I have found an older post which outlines how to get Att. Tags to display in the attachment page as links:

    https://wordpress.org/support/topic/show-tags-in-attachment-page/

    This is working great and I have changed the code so commas separate the words instead of paragraphs.

    Original code:

    $output = "<h3>Terms list for taxonomy: {$taxonomy}</h3>";
    	foreach ( $terms as $term ) {
    		$output .= '' . sprintf( '<a href=%1$s%2$s?my_taxonomy=%3$s&my_term=%4$s title="Gallery for %5$s">%6$s</a>', $site_url, $page_path, $taxonomy, $term->slug, $term->name, $term->name ) . "
    \n";

    My changes:

    $output = "Tags: ";
    	foreach ( $terms as $term ) {
    		$output .= ', ' . sprintf( '<a href=%1$s%2$s?my_taxonomy=%3$s&my_term=%4$s title="Gallery for %5$s">%6$s</a>', $site_url, $page_path, $taxonomy, $term->slug, $term->name, $term->name );

    But how can I prevent the leading comma and extra space from showing. What I have as it appears on the page now is:

    Tags: , installations, aircraft, atmosphere, deserts, landscapes, mars, metal, plains, planets, sky

    Also in general are the changes I made ok? I’m not sure if I should leave "\n" in or not. And I also took out {$taxonomy}

    Thanks,

Viewing 8 replies - 1 through 8 (of 8 total)
  • Sorry Original code should be:

    $output = "<h3>Terms list for taxonomy: {$taxonomy}</h3>";
    	foreach ( $terms as $term ) {
    		$output .= '<p>' . sprintf( '<a href=%1$s%2$s?my_taxonomy=%3$s&my_term=%4$s title="Gallery for %5$s">%6$s</a>', $site_url, $page_path, $taxonomy, $term->slug, $term->name, $term->name ) . "</p>\n";
    Plugin Author David Lingren

    (@dglingren)

    Thanks for the detailed description of your changes and the code excerpts. Overall, your changes look fine; removing the \n and {$taxonomy} are harmless and appropriate for your alternative display format.

    To remove the leading punctuation you can try something like this:

    $output = array();
    foreach ( $terms as $term ) {
        $output[] = sprintf( '<a href=%1$s%2$s?my_taxonomy=%3$s&my_term=%4$s title="Gallery for %5$s">%5$s</a>', $site_url, $page_path, $taxonomy, $term->slug, $term->name );
    }
    
    $output = "Tags: " . implode( ', ', $output );
    

    I haven’t actually run that code but it’s pretty straightforward. Note how I reused the fifth sprintf argument ( %5$s )and dropped the sixth argument.

    I am marking this topic resolved, but please update it if you have any problems or further questions regarding the above suggestion.

    hi David,

    It’s been while since I set this up with your help, since then I changed my lightbox from Photonic to Justified Image Grid.

    I can’t remember if the behavior was when a clickable tag on the attachment page is clicked, then navigates to the tag gallery page, that when in that page if user clicks on a media thumbnail, does user navigate to the attachment page. I think it was.

    So currently the lightbox is activated. It might be JIG determining this. I still need the lightbox to open in my attachment page mla gallery (which it does), but for the tag gallery, can this be set to take user to the attachment page when they click a thumbnail?

    thanks,

    Plugin Author David Lingren

    (@dglingren)

    Good to hear from you again. I want to make sure I understand your question.

    You wrote “for the tag gallery, can this be set to take user to the attachment page when they click a thumbnail?” It looks like the “tag gallery” is created by JIG; is that right? If so, JIG is determining the destination of any links behind the gallery thumbnail images; I don’t believe MLA is involved.

    I looked through the JIG documentation and the shortcode editor settings and I do not see an option to set the thumbnail link destination to the Attachment Page. Your best next step is to contact the JIG author and ask them if this is possible. If there’s anything MLA can do to help, post an update here.

    Thanks for checking that out David, much appreciated!

    Well the tag gallery is actually an MLA construction. I had it working before installing JIG, following your guidelines in the topic below and with additional help from this topic. I’m quite sure the thumbnails in the tag gallery linked to the attachment page before installing JIG.

    https://wordpress.org/support/topic/show-tags-in-attachment-page/

    I’ll ask JIG but because the tag gallery is an MLA custom code I think the author may enact the scratching head routine.

    I wonder if the tag gallery code can resume its default behavior of linking to the attachment page, by somehow bypassing the new kid on the block

    thanks,

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update. Perhaps I am not understanding your code completely or correctly.

    Can you post the code and/or source text you are currently using? Can you include more details on how JIG is involved? I’d like to try replicating your application on my own system so I can investigate further.

    I am traveling and away from my system but I can look into this next week. Thanks for your patience.

    hi David,

    I mucked around some more and tried various settings and had a breakthrough, and it’s elegant too.

    https://drive.google.com/open?id=16c11oMk2giPmwAFgRg1q6YCKds41GkRs

    The link is a screen grab of the Justified Image Grid lightbox settings. This is applied globally but the options here can be placed into a shortcode as well.

    The option ‘Attachment: Point images to the WP image attachment page’ has the corresponding shortcode attribute lightbox and the shortcode value attachment.

    lightbox=attachment

    I put this into your awesome tag gallery mla shortcode and walla! When a thumbnail on the tag gallery page is clicked the user is navigated to its attachment page

    thanks for your help,

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update and for sharing the solutions you found. That’s exactly what I was hoping to find; JIG options to accomplish your task. The MLA shortcode hands off control to JIG for composing the gallery and lightbox functions, so the Attachment Page link must come from JIG.

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