Support » Plugin: Media Library Assistant » Auto alt text from field in exif or iptc

  • Resolved perchera

    (@perchera)


    Hello,

    Sorry if this is duplicated but all topics i find are not completely related to my need.

    I use geosetter to edit the exif and iptc

    images results in having all the labels i need
    tittle,
    copyright,
    website,
    etc

    By doing that i get that the images i upload get the tittle of my images file names.
    I like to be descriptive in my file name prod-name-color-number-whatever.jpg to make it easier to find and to include all the relevant info about the image (mostly products)

    Problem comes with alt text
    It is blank by default.

    I know i can batch edit the alt text once uploaded with
    template:[+name_only,str_replace( ‘-‘, ‘ ‘ )+]
    So i get an alt text: “prod name color number whatever”

    1) what is the template to get “Prod Name Color Number Whatever”? (initial uppercase)
    2) but the ideal and the reason of this post:
    – i can easily batch enter my desired alt txt with geosetter in some empty exif/iptc field
    – how can i tell media assistant to use that field as the alt text

    The idea behind is that my files in my pc are already stored and containing all the info (including alt text) in case i need to reupload or re-batch

    I hope the above makes sense

    Thank you

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author David Lingren

    (@dglingren)

    Thanks for your questions and for the details of your application; very helpful. Thanks as well for the reference to the Geosetter tool, which looks quite powerful.

    You asked “i can easily batch enter my desired alt txt with geosetter in some empty exif/iptc field – how can i tell media assistant to use that field as the alt text“? You can access any IPTC, EXIF or XMP value by adding the appropriate field-level prefix to your data source, e.g., [+iptc:2#005+] or [+exif:DateTimeOriginal+]. You can find more information in the “Field-level Substitution Parameters” section of the Settings/Media Library Assistant Documentation tab. You can also access these values in an IPTC/EXIF mapping rule; see the “IPTC & EXIF Processing Options” section of the Documentation.

    You asked “what is the template to get “Prod Name Color Number Whatever”? (initial uppercase)“? There is no feature to do this in the current MLA version. However, I have taken the opportunity to add it to the “MLA Substitution Parameter Hooks Example” plugin as a custom format value. You can either install and activate the example plugin to get the feature or adapt the code to your theme or a plugin of your own.

    I have uploaded a new MLA Development Version dated 20200810 that includes an updated “MLA Substitution Parameter Hooks Example” plugin. You can find step-by-step instructions for using the Development Version in this earlier topic:

    PHP Warning on media upload with Polylang

    Once the Development Version is installed you must install and activate the example plugin. Navigate to the Settings/Media library Assistant Documentation tab and click the “Example Plugins” button. Type “substitution” in the text box and click “Search Plugins” to filter the table.

    You are looking for the “MLA Substitution Parameter Hooks Example” plugin. Find that plugin and hover over the title in the left-most column. Click the “Install” rollover action, then go to the WordPress Plugins/Installed Plugins submenu and activate the example plugin as you would any other plugin. Make sure you have the latest version, 1.13, installed. You can also click the “View” rollover action to view the source code of the plugin, which contains documentation and use notes displayed as comments at the beginning of the source code.

    Once the Development Version and updated example plugin are installed and active you can batch edit the ALT Text values with something like template:([+alt_text,ucwords+]) to apply the format to the current value. Note that this only works after you have initialized the ALT Text with your template:[+name_only,str_replace( '-', ' ' )+] template. You cannot have two option/format values in one step. You could also define an IPTC/EXIF mapping rule for the ALT Text field using the template:([+alt_text,ucwords+]) template.

    It would be great if you could install the Development Version and the example plugin and let me know if it works for you. Thanks for inspiring this MLA improvement.

    Plugin Author David Lingren

    (@dglingren)

    I have released MLA v2.84, which contains the updated “MLA Substitution Parameter Hooks Example” plugin. I am marking this topic resolved, but please update it if you have any problems or further questions regarding the new custom format. Thanks for inspiring this MLA enhancement.

    Hello David,

    Sorry for my late reply. I’ve been busy with another website and unable to try your hook. Thank you very much for taking the time to looking into it. I will test it today and let you know.

    I must be doing sth wrong…
    I’ve updated your plugin

    I go to media/assistant
    select one file (or many)
    pick edit/apply
    enter template:[+empty+] in the alt text field
    Press updtate. Fine alt text are blank

    Same with template:[+name_only,str_replace( ‘-‘, ‘ ‘ )+]
    Fine, alt text are now file name without “-” or ” ”

    Same with your new template
    template:([+alt_text,ucwords+])
    Nothing happens, all files are unchanged
    Some of my file names are “name-name-name-###-name”
    I was wondering if the ### (numbers) might be the reason
    Nope, i’ve tried the same templates with files containing only letter (no numbers) but still same, all files unchanged

    Removing “-” and ” ” works like charm but changing to upper case… i must be doing sth wrong for sure

    • This reply was modified 3 months, 3 weeks ago by perchera. Reason: spelling
    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update and for taking the time to try the new “ucwords” modifier.

    You mentioned updating MLA to the latest version, but did not make any reference to installing and activating the “MLA Substitution Parameter Hooks Example” plugin. That’s where the new “ucwords” code has been added.

    Have another look at the instructions following the “PHP Warning” link for more information. If you have installed and activated the example plugin and still have a problem, let me know.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.