• Resolved ratamatcat

    (@ratamatcat)


    Howdy,

    I’d like to be able to have a gallery based on the Title of an image in the Media Library. For example I upload the following set of five images, and rename their Titles as follows:

    Caves Sun Desert 01
    Caves Sun Desert 02
    Caves Sun Desert 03
    Caves Sun Desert 04
    Caves Sun Desert 05

    I want the gallery to display in the attachment page of the #1 image (Caves Sun Desert 01) by using do_shortcode with [mla_gallery] in the attachment.php template file. It chooses all images of the same title and orders them in the gallery according to the number.

    Is there such a parameter allows the selection of the media in this fashion. So the one mla gallery in the template is all that’s required as opposed to multiple mla galleries on various posts or pages.

    thanks,

Viewing 9 replies - 16 through 24 (of 24 total)
  • Thread Starter ratamatcat

    (@ratamatcat)

    Hi again,

    thanks for providing the debug code David. I put in this into the overlay gallery, and it’s displayed the following:

    https://drive.google.com/open?id=1LR4ZwUzZUpVjrFkAsWsa1MRakyVtFFMc

    I see that the problem is the overlay gallery is looking at the att tags for item 7256, which is the media item for the portrayal gallery with the tag ‘Portrayal: nebula stars dust (it’s the first item of the 17 items which all have this tag).

    The overlay gallery should be looking at item 7279, the first item of the 7 items which have the tag ‘Overlay: nebula stars dust’.

    There’s some sort of fundamental conflict between the portrayal and the overlay galleries. They are two separate galleries and are not required to have the same number of media items or any other connection.

    I must be doing something basic wrong that I haven’t been able to show you properly yet somehow.

    Thanks,

    Plugin Author David Lingren

    (@dglingren)

    I am happy to see the debug code was useful and shed some light on the cause of your issue. Your additional comments are helpful as well.

    Your attachment.php template displays the “Media Page” for a single item, in this case item 7256. That’s the source of the assigned terms, including the “Portrayal: nebula stars dust” term you selected for the first MLA gallery. I don’t see any way to “look at” item 7279 based on the information you have, but I can suggest an alternative.

    You already have “Portrayal: nebula stars dust” and all you need is “Overlay: nebula stars dust” because “nebula stars dust” ties the two galleries together. Try changing the second term-selection loop to something like:

    foreach ( $tags as $tag ) {
    	if ( 0 === strpos( $tag->name, 'Portrayal:' ) ) {
    		$slug = 'overlay' . substr( $tag->slug, strlen( 'portrayal' ) );
    		break;
    	}
    }
    

    The if test looks for Portrayal, which is assigned to item 7256. The $slug assignment statement combines the overlay prefix with the -nebula-stars-dust suffix that uniquely identifies the term you want.

    Let me know if that makes sense, and if it helps.

    Thread Starter ratamatcat

    (@ratamatcat)

    Hi David,

    Works perfectly, I’m wrapped.

    Really, the Title should be unique and descriptive for each item in the Media Library.

    Changing tack here, I have just encountered a situation where I now understand what you mean. I have created a select list custom field using the advanced custom fields plugin, set to display on media item edit screens. I need it to pick other media items for certain media items i.e. establishing a relationship, for some programming I want. Needless to say, it doesn’t help when the media library Title is precisely the same for 17 media items all named ‘Nebula Stars Dust’!

    I have the IPTC title field of the file set to map to the WordPress media library title. Is there a way to keep the IPTC value as ‘Nebula Stars Dust’ for my files, then automatically add a number suffix to each upon upload? For example in those 17 media items they each have the following value for the file metadata:

    Nebula Stars Dust

    When these come into media library instead of using the name as above for each, I want

    Nebula Stars Dust 1
    Nebula Stars Dust 2
    Nebula Stars Dust 3
    Nebula Stars Dust 4
    etc…

    If I put these into the IPTC title field as above it mucks around with the permalink that’s created. Plus I would prefer to have ‘Nebula Stars Dust’ for the IPTC value rather than the number suffix applied. It’s really only in WordPress that I need the numbers.

    It’s not a super important thing, because I can simply manually rename the media items once they are in WordPress, adding the numbers this way.

    thanks again,

    Plugin Author David Lingren

    (@dglingren)

    Thanks for the good news regarding my suggestions.

    Regarding your number suffix question, you can use MLA’s Bulk Edit feature to simplify renaming the media once they are added to the Library, as described in this earlier topic:

    Bulk rename of images

    I regret that renaming them during the original upload process is not possible because WordPress treats each upload as a separate transaction and has no way to indicate that multiple items are related in any way.

    Thread Starter ratamatcat

    (@ratamatcat)

    So all my media item titles are ‘Nebula Stars Dust’, and I want to add numbers to the end of a 17-image set.

    Thus I bulk edit as described in the link you provided, and insert following text in the Title field:

    template:Nebula Stars Dust [+index+]

    It works great except that the numbering is in the opposite order to desired, LOL

    so the item that’s been named Nebula Stars Dust 17, must be Nebula Stars Dust 1

    I tried selecting the items in different ways etc before selecting bulk edit

    Can the order be reversed somehow?

    thanks,

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your suggestion. I have added a new substitution parameter, [+reverse_index+], to the Bulk Edit template processing to give you the results you need. You can find more information in the Help menu “Bulk Actions” tab on the Media/Assistant screen.

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

    PHP Warning on media upload with Polylang

    It would be great if you can install the Development Version and let me know if it works for you. Thanks for inspiring an MLA enhancement.

    Thread Starter ratamatcat

    (@ratamatcat)

    Hi David, I installed the development version and it all processed smoothly with the reversed sequence. Many thanks.

    I could be being a bit cheeky but, is it also possible to produce a further variant of this action for my ‘overlays’ that have a main set number with a secondary number, i.e.

    Nebula Stars Dust 1.1
    Nebula Stars Dust 1.2
    Nebula Stars Dust 1.3
    etc

    thanks,

    Plugin Author David Lingren

    (@dglingren)

    Thanks for confirming that the new [+reverse_index+] substitution parameter is working for you.

    It looks to me like you can handle your overlays requirement by simply adjusting your template, e.g., something like:

    template:Nebula Stars Dust 1.[+reverse_index+]
    

    Does that make sense? I cannot see any general way to produce multiple levels of indexing.

    Thread Starter ratamatcat

    (@ratamatcat)

    I’m making fast progress with these techniques, this is excellent

Viewing 9 replies - 16 through 24 (of 24 total)
  • The topic ‘Gallery that uses the image Title’ is closed to new replies.