Title: MLA CSV Data Source Example. How to upload CSV?
Last modified: March 25, 2021

---

# MLA CSV Data Source Example. How to upload CSV?

 *  Resolved [blogdropper](https://wordpress.org/support/users/blogdropper/)
 * (@blogdropper)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/mla-csv-data-source-example-how-to-upload-csv-2/)
 * Hi,
    You say in the documentation:
 * > This means that the first step of the process is, of course, uploading the 
   > CSV file (or files) you want to use to your Media Library.
 * I tried to upload the csv file with updates to Media Library but am informed 
   this type of file is not allowed because it’s a security threat.
    How / Where
   do I make this file available to the plugin?
 * Thanks for your help

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Thread Starter [blogdropper](https://wordpress.org/support/users/blogdropper/)
 * (@blogdropper)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/mla-csv-data-source-example-how-to-upload-csv-2/#post-14238441)
 * Simple! MLA > settings > Uploads tab
    tick “always use MLA MIME type” Save Changes
   Now you can upload a csv file to the Media Library.
 * Hope this helps somebody
 *  Thread Starter [blogdropper](https://wordpress.org/support/users/blogdropper/)
 * (@blogdropper)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/mla-csv-data-source-example-how-to-upload-csv-2/#post-14239487)
 * Once I’ve uploaded the csv file how do I implement the updates specified in the
   file.
    The documentation describes the csv file in great detail, but doesn’t 
   say how to use it to update image metadata – or am I missing it? Any help much
   appreciated. Thanks
 *  Plugin Author [David Lingren](https://wordpress.org/support/users/dglingren/)
 * (@dglingren)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/mla-csv-data-source-example-how-to-upload-csv-2/#post-14240946)
 * Regarding the CSV “security threat”, you have found the solution I proposed in
   your other topic with this same name:
 * [MLA CSV Data Source Example. How to upload CSV?](https://wordpress.org/support/topic/mla-csv-data-source-example-how-to-upload-csv/#post-14240870)
 * Regarding the MLA CSV Data Source Example plugin, the key to using it is understanding
   that it simply provides an additional “data source” that is used in the same 
   way the other MLA data sources are used. Have a look at the “Field-level Substitution
   Parameters” section of the Settings/Media Library Assistant Documentation tab.
   With the example plugin you have a new `csv:` prefix that accesses the columns
   in your CSV file for use in mapping rules or the `[mla_gallery]` shortcode. You
   can use any column names that make sense for your application. The only special
   column names are the ones used to match your CSV rows to Media Library items.
 * You asked “**_how to use it to update image metadata_**“? You can find information
   on updating the image metadata in the “Custom Field and Attachment Metadata Processing
   Options” section of the Documentation tab. There is a “Adding or changing Attachment
   Metadata” subsection there that includes an example you can adapt for your task.
 * To update WordPress standard fields like the Title or Description you can use
   the IPTC/EXIF mapping rules outlined in the “IPTC & EXIF Processing Options” 
   Documentation section. The “EXIF/Template mapping with Content Templates” section
   will be helpful; you would use the `csv:` prefix in the same way the `xmp:` prefix
   is used in that material.
 * Content templates can also be used in the Bulk Edit area on the Media/Assistant
   admin submenu to perform one-time bulk editing of fields like Title and Description.
   The pull-down Help menu on that screen has more specific guidance.
 * I will leave this topic unresolved for now in case you have problems or further
   questions regarding the above suggestions.
 *  Thread Starter [blogdropper](https://wordpress.org/support/users/blogdropper/)
 * (@blogdropper)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/mla-csv-data-source-example-how-to-upload-csv-2/#post-14241450)
 * Hi David,
    Does this look like a correct template for the csv file:
 *     ```
       template:([+csv:base_file,ID,post_title,post_parent,guid+])
       ```
   
 * I want to update image title and add a redirect to post_parent
 * Thanks
 *  Plugin Author [David Lingren](https://wordpress.org/support/users/dglingren/)
 * (@dglingren)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/mla-csv-data-source-example-how-to-upload-csv-2/#post-14241586)
 * Thanks for your update with the additional information. It looks like you are
   trying to do two things:
    1. Update the Title field for the Media Library item
    2. Add a redirect to the post/page to which the item is attached
 * Does that look right? I assume that `base_file,ID,post_title,post_parent,guid`
   are the field/column names in your CSV file; is that right? I assume that the`
   ID` is the field name you are matching on; is that right? To do that you must
   select `ID` in the “Match on” dropdown control found on the Settings/MLA CSV 
   Data General tab. Once that’s done MLA will match the value in the CSV’s ID field
   to the ID value for each Media Library item and then make the other `csv:` values
   available for use with that item.
 * Let me try to clarify how this all works. The `csv:` prefix is used with exactly
   one field name to access one of the fields in your CSV file. For example, `[+
   csv:post_title+]` would access the `post_title` field in your CSV file.
 * To access the `post_title` field you would code something like:
 *     ```
       template:([+csv:post_title+])
       ```
   
 * If you want to use this value to replace the Title value for a Media Library 
   item you would define an IPTC/EXIF mapping rule for the Title standard field,
   or use the template in the Bulk Edit area of the Media/Assistant admin submenu.
 * I do not understand what you mean by “add a redirect to post_parent”. It looks
   like you want to compose a gallery of one or more items and make each gallery
   item a clickable link to the item’s parent. If that’s right you don’t need anything
   in the CSV file to accomplish your goal. You would use the `page_url` substitution
   parameter to compose the link for those gallery items. I can give you more specific
   guidance if you can give me more details of your meaning.
 *  Thread Starter [blogdropper](https://wordpress.org/support/users/blogdropper/)
 * (@blogdropper)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/mla-csv-data-source-example-how-to-upload-csv-2/#post-14241918)
 * Thanks very much for taking the time to explain all this, much appreciated.
    
   So I now have the following:
 *     ```
       CSV File:
       =========
       Title,ID,post_type
       Adiantum capillus,39507,attachment
       Adiantum capillus,39508,attachment
   
       CSV MLA Template:
       =================
       template:([+csv:post_title+])
       template:([+csv:ID+])
       template:([+csv:post_type+])
   
       page_url substitution parameter:
       ================================
       mla_link_href='{+page_url+}'
   
       clickable link to the item’s parent:
       ====================================
       https://florapalaestina-ethnobotany.org/?plant=Adiantum-capillus-veneris/
       ```
   
 * I have a total of around 500 images, the csv file will have a row for each image.
   
   Where do I put the clickable link to each image and how do I apply all this to
   the images?
 * Thanks
 *  Plugin Author [David Lingren](https://wordpress.org/support/users/dglingren/)
 * (@dglingren)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/mla-csv-data-source-example-how-to-upload-csv-2/#post-14243758)
 * Thanks for your update with the details on your file layout and templates.
 * Regarding the file layout, I do not see any need for the `post_type` column, 
   but it’s harmless if you have some other purpose for it.
 * I think the only template you need is `template:([+csv:post_title+])` I explain
   how to use that below.
 * You asked “**_Where do I put the clickable link to each image_**“? You don’t 
   need the CSV file or a mapping rule to accomplish this task. The gallery display
   is generated by the `[mla_gallery]` shortcode. The clickable link is specified
   as a shortcode parameter. Here is a simple example you can add to a post or page
   to see how it works:
 *     ```
       [mla_gallery post_parent=any mla_link_href='{+site_url+}/?p={+post_parent+}']
       ```
   
 * In this example, the `post_parent=any` will select all of your Media Library 
   images that are attached to a post or page. The `mla_link_href=` parameter changes
   the link assigned to each gallery item. It uses the WordPress “plain permalink”
   format to link to the item’s parent. You can find more information on each of
   these parameters in the MLA Gallery sections of the Settings/Media Library Assistant
   Documentation tab.
 * By the way, my earlier reference to the `{+page_url+}` was incorrect. That value
   contains the URL of the post/page in which the `[mla_gallery]` shortcode is contained.
   It isn’t helpful for your application, and I regret the confusion.
 * You asked “**_how do I apply all this to the images_**“? To replace the default
   Title value for your Media Library items with the values in your CSV file you
   need to 1) use the “Edit” Bulk Action on the Media/Assistant admin submenu and
   enter the template in the “Title” text box on the form, or 2) create and execute
   an IPTC/EXIF mapping rule. If you want to replace ALL the Title values the mapping
   rule is the way to go. To do that:
    1. Go to the Settings/Media Library Assistant IPTC/EXIF tab.
    2. Locate the “Title” rule entry in the table and click the “Edit” rollover action.
    3. In the “IPTC Value” dropdown control leave the default “- None (select a value)-”
       in place.
    4. In the “EXIF/Template Value” text box enter “template:([+csv:post_title+])” (
       without the quotes)
    5. In the “Priority” dropdown, select “EXIF”.
    6. In the “Existing Text” dropdown, select “Replace” to replace existing default
       Titles.
    7. In the “Status” dropdown, select “Active”.
    8. Scroll down to the bottom of the screen and click “Update”.
 * Once you define the rule you can apply it to a single item, multiple items or
   all items:
    - To map a single item, go to the Media/Assistant submenu and click the thumbnail
      of the item you want (or click the “Edit” rollover action) to get the Media/
      Edit Media screen. You can click the “Map IPTC/EXIF metadata” link to run 
      your rules on this item, then look at the “Title” text box to inspect the 
      results.
    - To map two or more items, go to the Media/Assistant submenu and click the 
      checkbox next to the items you want. Then, select “Edit” from the “Bulk Actions”
      dropdown above the checkboxes and click “Apply” to open the Bulk Edit area.
      Click the “Map IPTC/EXIF metadata” button to run your rule on the selected
      items.
    - To map all of your items, stay on the Settings/Media Library Assistant IPTC/
      EXIF tab and click the “Execute” rollover action for the Title rule. This 
      may take a while.
 * These methods will apply all IPTC/EXIF rules to the selected item(s). This won’t
   be a problem if you have only the one rule. The third method might be the best
   for your application. Because your template includes parentheses around the `([
   +csv:post_title+])` value the rule will only affect items that have a row in 
   the CSV file. You can start small by using a CSV file with one or a small number
   of rows, then scale it up when you have confidence in the results.
 * I hope that gives you the details you need to complete your application. I will
   leave this topic unresolved and hope to hear back from you soon.
 *  Thread Starter [blogdropper](https://wordpress.org/support/users/blogdropper/)
 * (@blogdropper)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/mla-csv-data-source-example-how-to-upload-csv-2/#post-14246441)
 * Hi David,
    Thanks for the full explanation.
 * You say
 * > The clickable link is specified as a shortcode parameter.
 * I’m really interested in updating the media library metadata using the CSV file
   option.
    Is it possible to input this link into the csv file with the post_title,
   also how would I add a description field for an image into the csv file? What
   would be the templates?
 * Thanks for your help
 *  Plugin Author [David Lingren](https://wordpress.org/support/users/dglingren/)
 * (@dglingren)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/mla-csv-data-source-example-how-to-upload-csv-2/#post-14246735)
 * I am not sure I understand what you want to accomplish. You wrote “**_I’m really
   interested in updating the media library metadata using the CSV file option._**”
   I do not understand what you mean by “**_the media library metadata_**“.
 * The intent of the CSV file as a data source is to let you transfer data from 
   a CSV file into the WordPress database. There are WordPress standard fields like
   Title, ALT Text, Caption and Description. The mapping rule example I gave in 
   my last post shows you how to transfer a value from the CSV file into a standard
   field.
 * WordPress also provides custom fields. You can define a mapping rule to transfer
   values from the CSV file to a custom field. For images, there is also the “Attachment
   Metadata” field, which includes details on the intermediate size files WordPress
   creates as well as an “image_meta” array with some additional values. MLA lets
   you update or add to these values with a mapping rule.
 * You asked “**_how would I add a description field for an image into the csv file?_**”
   There is no MLA function to add data **to **the CSV file itself. You build the
   CSV file in any way you want, upload it to the Media Library and then take values**
   from **the CSV file and put them somewhere in the database.
 * If you want to update the Description standard field from a value in the CSV 
   file you would create a mapping rule for the Description field in exactly the
   same way as the Title example I gave in my earlier post.
 * I hope that helps. If you can tell me more specifically where you want to store
   the data I can give you more detailed guidance.
 *  Thread Starter [blogdropper](https://wordpress.org/support/users/blogdropper/)
 * (@blogdropper)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/mla-csv-data-source-example-how-to-upload-csv-2/#post-14270797)
 * Hi David,
    I finally succeeded to do what I wanted. Thanks for taking the time
   to explain all this to me. Here’s the csv I used:
 *     ```
       Caption,ID
       "<a href=""https://florapalaestina-ethnobotany.org/?plant=Acacia-farnesiana/"" target=""_blank""><div class=""flex3""><div class=""flex-items""><b>Acacia farnesiana</b></div><div class=""flex-items pad5""> <ul><li>שִׁטַּת הַמְּשׂוּכוֹת</li></ul></div></div><div class=""flex3 pad10""><div class=""flex-items""> <ul><li>Sweet Acacia</li><li> Needle Bush</li></ul></div><div class=""flex-items""> <ul><li>طلح أنباري</li><li>  طلح الفتنة</li><li>  طلح حلو</li></ul></div></div></a>",42391
       "<a href=""https://florapalaestina-ethnobotany.org/?plant=Acanthus-hirsutus/"" target=""_blank""><div class=""flex3""><div class=""flex-items""><b>Acanthus hirsutus</b></div><div class=""flex-items pad5""> <ul><li>קוֹצִיץ סוּרִי</li></ul></div></div><div class=""flex3 pad10""><div class=""flex-items""> <ul><li>Syrian Bears-breech</li><li> Syrian acanthus</li></ul></div><div class=""flex-items""> <ul><li>خنزيري</li></ul></div></div></a>",42392
       "<a href=""https://florapalaestina-ethnobotany.org/?plant=Achillea-arabica/"" target=""_blank""><div class=""flex3""><div class=""flex-items""><b>Achillea arabica</b></div><div class=""flex-items pad5""> <ul><li>אָכִילֵאָה קְטַנַּת-פְּרָחִים</li></ul></div></div><div class=""flex3 pad10""><div class=""flex-items""> <ul><li>Yellow Milfoil</li></ul></div><div class=""flex-items""> <ul><li>أخيليا</li><li>  زقزقة العصفور</li><li>  بعيثران</li></ul></div></div></a>",39701
       ```
   
 * and here’s [what it looks like](https://florapalaestina-ethnobotany.org/photo-gallery/)
 * Seems to me that the internet’s one of the few places you can find altruism.
   
   Thanks for making this possible
 *  Plugin Author [David Lingren](https://wordpress.org/support/users/dglingren/)
 * (@dglingren)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/mla-csv-data-source-example-how-to-upload-csv-2/#post-14273607)
 * Thanks for the good news about your success and especially for the link to your
   end results. What a great site and a fascinating project!
 * I am marking this topic resolved, but please update it if you have any problems
   or further questions regarding the MLA CSV Data Source Example plugin.
 * Thanks again for your interest in MLA and for letting me see how it’s being used.

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘MLA CSV Data Source Example. How to upload CSV?’ is closed to new replies.

 * ![](https://ps.w.org/media-library-assistant/assets/icon-256x256.png?rev=973502)
 * [Media Library Assistant](https://wordpress.org/plugins/media-library-assistant/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/media-library-assistant/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/media-library-assistant/)
 * [Active Topics](https://wordpress.org/support/plugin/media-library-assistant/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/media-library-assistant/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/media-library-assistant/reviews/)

 * 11 replies
 * 2 participants
 * Last reply from: [David Lingren](https://wordpress.org/support/users/dglingren/)
 * Last activity: [5 years, 1 month ago](https://wordpress.org/support/topic/mla-csv-data-source-example-how-to-upload-csv-2/#post-14273607)
 * Status: resolved