How to tag a batch of images

Hi everyone,

I am trying to tag pictures, but I can’t find the way to tag a batch of them, like you can do with Sets.
I am using Grand Gallery block, and I need to tag the pics so the filters work.

Thank you!

V.

I will copy message from support forum for future reference:

It’s not possible with current User Interface in Grand Gallery.
But you should be able to do it in Concrete File Manager (/dashboard/files/search).

You have to select multiple images by holding CTRL ot SHIFT button, and then
click down arrow in top left corner (next to “Name” Label) → Click Properties → and continue as usual.
This way you will assign Tags to multiple images.

If you select multiple images and right click one of them directly (and not using that arrow button) → it will make changes only to one clicked image. It’s bad design usability-wise, people often miss that mass-assignment arrow, but it is what it is. Hope it helps.

Cheers

Hi there,
Thank you for your reply.
That’s the way I was doing it, it is not working.
Can it be a bug from the last version?
V

I have tested it on latest version of Concrete5.8, what is yours?

Hi,
Batch tagging is not working neither in version 9.1.0 nor 9.1.1.
Is this a bug?
Thank you!
V.

Well, here is a more specific description of the problem: When I add a new Option List attribute to Files, and afterwards I select a batch of images and try to settle the new attribute to a specific value for all of them, and save the changes, only the first of the images gets the input. If I do it one by one, it does work.
Also, I wonder why when you select a batch of images, and then edit details, you get by default only 3 attributes: width, height and duration. But if you click on a single image, you get 3 more attributes: title, description and tags.

It seems you can only mass edit custom attributes, not Basic Properties.
It doesn’t matter though, because Grand Gallery uses its own attribute “Gallery Tags” (handle: gg_tags). If it somehow doesn’t exist, then you can create it by yourself in dashboard.

Also there is a chance that you are looking at wrong attribute. Don’t confuse built-in “Tags” attribute (this is not used) with “Gallery Tags” (this one is used by Grand Gallery).

Mass assignment should override existing “Gallery Tags” attribute of selected images. I do have error when clicking on trash icon, but it seems working as intended otherwise.

I have just read that you are using Concrete 9 version. I’ll check it an let you know, maybe something is bugged indeed.

Thank you Parasek. When I selected the images after installing Grand Gallery, I was able to add the new attribute Grand Gallery tag to the pictures, and add new values to its option list. The tag was added, but I was unable to batch settle any value to it, unless I go one by one. I hope it helps, thank you!.

Yeah, it seems bugged right now in 9.1.1.
Only first image is changed when mass-assigning custom attributes.
You have to wait till it will be fixed in core release or I can post example code for mass-assigning tags to images grouped in File Set (if you have access to files on server and want go that way).

That would be nice, thank you!

If website is actually live, remember to turn Maintenance mode on.

Paste code somewhere (for example in application/bootstrap/app.php).
Change name of File Set and add Tags at the beginning of code.
Refresh any page of your site in browser.
Remove code afterward.

Keep an eye on “Gallery Tags” attribute if extra tags are not created by accident (but they shouldn’t if I didn’t mess anything up):
yoursite.com/dashboard/files/attributes

// Mass assign tags to images in File Set
// This will clear already selected tags
$fileSet = \Concrete\Core\File\Set\Set::getByName('Name of File Set');
$newTags = [
    'Tag 1',
    'Tag 2',
];

if (is_object($fileSet)) {

    // Get images from File Set
    $list = new \Concrete\Core\File\FileList();
    $list->filterBySet($fileSet);
    $list->sortByFileSetDisplayOrder();
    $images = $list->getResults();

    if (count($images)) {
        foreach ($images as $image) {
            // Get existing tags
            $existingTags = [];
            $attributeKey = \FileAttributeKey::getByHandle('gg_tags');
            /** @var \Concrete\Core\Entity\Attribute\Value\Value\SelectValueOption[] $options */
            $options = $attributeKey->getController()->getOptions();
            foreach ($options as $option) {
                $existingTags[$option->getSelectAttributeOptionID()] = $option->getSelectAttributeOptionValue();
            }
            // Add new tags to image
            $selectedOptions = [];
            if (is_array($newTags)) {
                foreach ($newTags as $newTag) {
                    $foundKey = array_search($newTag, $existingTags);
                    if ($foundKey) {
                        $option = \Concrete\Attribute\Select\Option::getByID($foundKey);
                    } else {
                        $option = \Concrete\Attribute\Select\Option::add(\FileAttributeKey::getByHandle('gg_tags'), $newTag);
                    }
                    $selectedOptions[] = $option;
                }
            }
            $image->setAttribute('gg_tags', $selectedOptions);
        }
    }
}
echo '<pre>' . var_export('Assigning tags to images in File Set has ended.', true) . '</pre>';
exit;
1 Like

YOU RULE MAN!!! That was AWESOME! Thank you!!!

V.

1 Like