4

Is there a way to add tags to uploaded images (stored in vocabulary under admin/structure/taxonomy/tags/edit)

There is just alt and title fields as default at the moment....

I want users to add/ search tags that relate to images and not nodes (e.g. term reference)

I have found this module Taxonomy Images but it stops at D6 and I have D7

Ideally I would like something like this: enter image description here

2 Answers 2

4

You can use a combination of the modules File Entity and File Entity Inline. File Entity will allow you to add fields to different file types, including images, and File Entity Inline will display all those added fields after clicking "Upload" whenever a user creates or edits content.

In order to make this work with Multiupload Imagefield Widget, you will need to apply two patches, one patch to multiupload_imagefield_widget.module, and one patch to file_entity_inline.module.

These patches are simple enough that they can be applied manually.

  1. First install the modules File Entity and File Entity Inline. Go to Structure > File types > Image > Manage field and add the Term Reference field you want and any other fields you desire for the Image file

  2. Apply the patches. For the sake of convenience I'm pasting below the lines that need to be replaced.

In the directory where your drupal installation lives in the server, find the file multiupload_imagefield_widget.module, usually located under the path sites/all/modules/multiupload_imagefield_widget. Add the following lines at the very end of the file:

/**
 * Implements hook_file_entity_inline_widgets().
 */
function multiupload_imagefield_widget_file_entity_inline_widgets() {
  $widgets = array();
  $widgets['image_miw'] = array(
    'element_type' => 'mfw_managed_file',
  );
  return $widgets;
}

Save.

Then find the file file_entity_inline.module, usually in the path sites/all/modules/file_entity_inline/. Find the line:

if (empty($element['fid']['#value']) || !isset($element['#entity_type']) || !isset($element['#field_name'])) {

and replace it for:

if (empty($element['#value']['fid']) || !isset($element['#entity_type']) || !isset($element['#field_name'])) {

and find the line:

$file = !empty($element['#file']) ? $element['#file'] : file_load($element['fid']['#value']);

and replace it for:

$file = !empty($element['#file']) ? $element['#file'] : file_load($element['#value']['fid']);

Save.

Go back to your site, clear the cache. Then you should be good to go. Be sure to select Multiupload as the widget for the Image field. After selecting the files and clicking Upload, the page will show thumbnails for each file and whatever fields you have added to the image file entity in step 1.

ONE BIG CAVEAT: If you ever install an update or upgrade for either patched module, you will lose your patches, unless they are "committed" to the new module versions. The maintainers of both modules seem to be dragging their feet committing these patches. Multiupload Imagefield Widget has had two new versions without this patch being committed. File Entity Inline hasn't been updated in at least 3 years...

9
  • I have installed File Entity and File Entity Inline but I don't know how to do what you have suggested me! I have seen the documentation link but it just says what it does. link Could you please tell me what to add to my upload content type?
    – testing1
    Commented Jan 12, 2016 at 17:24
  • OK. I'll write back in a few hours. Really busy now! Are you usig Multiupload Imagefield Widget for your multiple uploads?
    – argiepiano
    Commented Jan 12, 2016 at 18:12
  • Yes, I am using Multiupload Imagefield Widget. Ideally I will need something like the image I have attached above. Many thanks for your help, look forward in seeing solution!
    – testing1
    Commented Jan 12, 2016 at 18:30
  • See my edited answer
    – argiepiano
    Commented Jan 13, 2016 at 3:17
  • Just about to start putting your answer into practice but before I do Both patches send me on the same link! Is this the right one for the file entity inline module? drupal.org/node/1864528
    – testing1
    Commented Jan 13, 2016 at 15:13
0

Try using field collections, create a field collection with Image field and Taxonomy Term field and use it instead in the content type.

2
  • This is great but the user can only add one picture at the time and has to click 'add another item' each time --- I need the user to select multiple pictures all in one go and the Tags bar to be next to each image uploaded! (I have Multiupload module installed)
    – testing1
    Commented Jan 12, 2016 at 15:26
  • check drupal.org/project/media_browser_plus
    – nikunj
    Commented Jan 12, 2016 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.