The Google Cloud Vision API offers following features- Landmark Detection, Logo Detection and Optical Character Recognition, in addition to the Label Detection feature.
These can be useful to fill the alt text/title text by default.
These features would be used to fill the alt text of the image file based on the choice given by the end user.
The user can check the checkboxes present in the Edit form of the Image File entity, and on its basis, the alt text would be appropriately filled.
Remaining Tasks:
Create a patch which would fill the alt text of the image file entity.
(This is one of the tasks of my GSOC 2016 Project.)
Comments
Comment #2
ajalan065 commentedHere is the first patch for the landmark detection, and storage of the result in the Alt Text of the image file.
As the use of services was already committed to the module, the patch is built over that.
Comment #3
ajalan065 commentedThe previous patch had some extra parameters, which have been removed in this patch
Comment #4
eugene.ilyin commentedI think that approach of the label detection is better for alt attribute. Because not all the images have landmarks, but I think that all images have the label.
Using of the Landmark detection can be useful, but I don't think that makes sense to fill alt by landmark by default.
Can we have the feature to fill alt by landmark but make it configurable?
What do you think about it?
Comment #5
ajalan065 commentedWe may have labels filled in the alt attribute. But we already have those data in the taxonomy terms.
IMHO, it would be better if we use the alt attribute to show the data from Landmark/Logo/Text within the images.
Comment #6
eugene.ilyin commentedTaxonomy terms as tags and filling the alt attribute are two different features. Please do not confuse it.
For me as an end user would be nice to be able enable checkbox "Fill alt/title by Google Vision API" and select method: Label Detection or Landmark or etc...
Comment #7
ajalan065 commentedComment #8
ajalan065 commentedComment #9
ajalan065 commentedHere is the patch which provides options for the image file to set the alt text for the file by one of the four methods- Label, Landmark, Logo and Optical Texts.
Comment #10
naveenvalechaif there will be no response then $output would never set.
Add a check if $output is available then set the value. See the review above in case 'labels'
Rest looks good to me.We need test coverage for this as well.
Comment #11
ajalan065 commentedHere is the patch following the suggestions of #10 along with the tests.
Please review :)
Comment #12
eugene.ilyin commentedCould you explain what is "field_image_alt_text" and why is it hardcoded?
Comment #13
ajalan065 commentedAlt text field remains already present on setting the drupal environment in the simple webtests, with the name "field_image_alt_text".
Hence, I directly used that value.
Comment #15
eugene.ilyin commentedCommitted.
I have several remarks:
1. Please check my additional commit. If you don't agree with something, please let me know.
2. Why do you use name "features" for this functionality? This name looks pretty abstract.
3. If the user will select any option for "features" he will be not able to disable it. Please add the option "none".
4. I think that better to fill "alt" field only if it's empty. Better to give the user ability to overwrite the alt for certain image manually.
Comment #16
ajalan065 commentedHi eugene.ilyin
#1- I will check the commit, and would inform you by tomorrow.
#2- I had derived the name "features" from the functionality of the Cloud Vision API.
#3- I will add the option "none" and post the new patch by tomorrow
#4- The alt field is filled as soon as the file is uploaded. At that moment, the field remains always empty. However, the user may override the value if he feels.
Comment #17
eugene.ilyin commentedI propose to change it. Features is too abstract name. What about "alt_auto_filling" or something like this?
No in "google_vision_entity_presave" you always override alt on value from Google Vision. There is no way to set custom alt.
Comment #18
naveenvalecha+1 to this.
Comment #19
ajalan065 commentedHere is the patch which allows the edit of alt text after it is filled by the vision api.
Also, the "features" is replaced.
Please review :)
Comment #20
naveenvalechaWhy this case ?
can't we use the default value if there's not any case ?
Comment #21
ajalan065 commentedHi naveenvalecha, the case "none" was added so that the user may switch to option "none" if he does not want to fill the alt text.
As, I had added the option "None", so instead of using the default case, I thought better to use that specific option.
Comment #22
naveenvalechaAdd a @TODO here to move this to the service later if there will be more helper functions like this.
Rest looks good to go.Thanks!
Comment #23
ajalan065 commentedAdded the @todo as suggested.
Comment #24
naveenvalechaIgnore the #23 patch and interdiff.
i have filed a followup issue for it https://www.drupal.org/node/2776441
Still RTBC for #19
Assigning to eugene for final look into this.
Comment #25
naveenvalechaComment #26
naveenvalechaPatch in #19 no longer applies to head. Please reoll it.
Comment #27
ajalan065 commentedHere is the rerolled patch.
Comment #28
naveenvalechaComment #29
naveenvalechaAdd a followup to move this function to a helper service.
Comment #30
naveenvalechaCommitted and pushed to 8.x-1.x
Thanks!
Comment #32
ajalan065 commentedYa, I am working on moving the functions to the helper service, and would post the patch in the follow up issue.