# How to tag a batch of images

**URL:** https://forums.concretecms.org/t/how-to-tag-a-batch-of-images/3110
**Category:** Using Concrete / Help
**Created:** [May 26, 2022, 5:23pm UTC](https://forums.concretecms.org/t/how-to-tag-a-batch-of-images/3110 "2022-05-26T17:23:15Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![byvictoria](https://forums.concretecms.org/user_avatar/forums.concretecms.org/byvictoria/32/5493_2.png) [@byvictoria](https://forums.concretecms.org/u/byvictoria)
#### Post date: [May 26, 2022, 5:23pm UTC](https://forums.concretecms.org/t/how-to-tag-a-batch-of-images/3110/1 "2022-05-26T17:23:15Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Parasek](https://forums.concretecms.org/user_avatar/forums.concretecms.org/parasek/32/4286_2.png) [@Parasek](https://forums.concretecms.org/u/Parasek)
#### Post date: [May 27, 2022, 6:42am UTC](https://forums.concretecms.org/t/how-to-tag-a-batch-of-images/3110/2 "2022-05-27T06:42:18Z")

</div>

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

---

<div class="post-metadata">

### Author: ![byvictoria](https://forums.concretecms.org/user_avatar/forums.concretecms.org/byvictoria/32/5493_2.png) [@byvictoria](https://forums.concretecms.org/u/byvictoria)
#### Post date: [May 27, 2022, 12:35pm UTC](https://forums.concretecms.org/t/how-to-tag-a-batch-of-images/3110/3 "2022-05-27T12:35:49Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Parasek](https://forums.concretecms.org/user_avatar/forums.concretecms.org/parasek/32/4286_2.png) [@Parasek](https://forums.concretecms.org/u/Parasek)
#### Post date: [May 27, 2022, 1:22pm UTC](https://forums.concretecms.org/t/how-to-tag-a-batch-of-images/3110/4 "2022-05-27T13:22:46Z")

</div>

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

---

<div class="post-metadata">

### Author: ![byvictoria](https://forums.concretecms.org/user_avatar/forums.concretecms.org/byvictoria/32/5493_2.png) [@byvictoria](https://forums.concretecms.org/u/byvictoria)
#### Post date: [May 27, 2022, 9:47pm UTC](https://forums.concretecms.org/t/how-to-tag-a-batch-of-images/3110/5 "2022-05-27T21:47:01Z")

</div>

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

---

<div class="post-metadata">

### Author: ![byvictoria](https://forums.concretecms.org/user_avatar/forums.concretecms.org/byvictoria/32/5493_2.png) [@byvictoria](https://forums.concretecms.org/u/byvictoria)
#### Post date: [May 28, 2022, 2:38am UTC](https://forums.concretecms.org/t/how-to-tag-a-batch-of-images/3110/6 "2022-05-28T02:38:36Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Parasek](https://forums.concretecms.org/user_avatar/forums.concretecms.org/parasek/32/4286_2.png) [@Parasek](https://forums.concretecms.org/u/Parasek)
#### Post date: [May 28, 2022, 7:18am UTC](https://forums.concretecms.org/t/how-to-tag-a-batch-of-images/3110/7 "2022-05-28T07:18:47Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Parasek](https://forums.concretecms.org/user_avatar/forums.concretecms.org/parasek/32/4286_2.png) [@Parasek](https://forums.concretecms.org/u/Parasek)
#### Post date: [May 28, 2022, 7:20am UTC](https://forums.concretecms.org/t/how-to-tag-a-batch-of-images/3110/8 "2022-05-28T07:20:16Z")

</div>

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

---

<div class="post-metadata">

### Author: ![byvictoria](https://forums.concretecms.org/user_avatar/forums.concretecms.org/byvictoria/32/5493_2.png) [@byvictoria](https://forums.concretecms.org/u/byvictoria)
#### Post date: [May 28, 2022, 1:11pm UTC](https://forums.concretecms.org/t/how-to-tag-a-batch-of-images/3110/9 "2022-05-28T13:11:52Z")

</div>

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!.

---

<div class="post-metadata">

### Author: ![Parasek](https://forums.concretecms.org/user_avatar/forums.concretecms.org/parasek/32/4286_2.png) [@Parasek](https://forums.concretecms.org/u/Parasek)
#### Post date: [May 30, 2022, 5:02pm UTC](https://forums.concretecms.org/t/how-to-tag-a-batch-of-images/3110/10 "2022-05-30T17:02:20Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![byvictoria](https://forums.concretecms.org/user_avatar/forums.concretecms.org/byvictoria/32/5493_2.png) [@byvictoria](https://forums.concretecms.org/u/byvictoria)
#### Post date: [May 30, 2022, 6:51pm UTC](https://forums.concretecms.org/t/how-to-tag-a-batch-of-images/3110/11 "2022-05-30T18:51:10Z")

</div>

That would be nice, thank you!

---

<div class="post-metadata">

### Author: ![Parasek](https://forums.concretecms.org/user_avatar/forums.concretecms.org/parasek/32/4286_2.png) [@Parasek](https://forums.concretecms.org/u/Parasek)
#### Post date: [May 31, 2022, 10:53am UTC](https://forums.concretecms.org/t/how-to-tag-a-batch-of-images/3110/12 "2022-05-31T10:53:28Z")

</div>

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`

```auto
// 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;

```

---

<div class="post-metadata">

### Author: ![byvictoria](https://forums.concretecms.org/user_avatar/forums.concretecms.org/byvictoria/32/5493_2.png) [@byvictoria](https://forums.concretecms.org/u/byvictoria)
#### Post date: [May 31, 2022, 5:26pm UTC](https://forums.concretecms.org/t/how-to-tag-a-batch-of-images/3110/13 "2022-05-31T17:26:50Z")

</div>

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

V.
