• Resolved cmyck

    (@cmyck)


    Hi,

    I was wondering, if it was possible to add a sorting option to the media library view that sorts by filename.
    I am naming my photos starting with YYYYMMDD, so I have an easy way to order them chronologically.
    The file order option orders them by title and there is not way to order them by their actual filename.

    Can this be done somehow?

    Thanks!
    cmyck

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter cmyck

    (@cmyck)

    It can: https://wordpress.stackexchange.com/questions/84030/add-file-name-column-to-media-library/409868#409868

    But the grid view is still not sortable.
    This is kinda primitve, IMHO.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your question and for sharing the solution you posted on StackExchange.

    I pasted your StackExchange code into my test system and ran some tests. On my system the column is added to the Media/Library List View but clicking on the column heading does not sort the items properly. The “orderby” value only works if it refers to a column in the database.

    You can use an MLA Custom Field mapping rule to copy the file name to a WordPress custom field, which can be used to create a sortable column in the Media/Assistant submenu table. To define your rule:

    1. Navigate to the Settings/Media Library Assistant “Custom Fields” tab.
    2. Scroll down to the “Add New Custom Field Rule” area below the “Enable” checkboxes.
    3. Click “Enter new field” to enter the custom field name manually. In the “Name” text box, enter your field name, e.g., “File Name”.
    4. From the Data Source dropdown list, select “file_name” or perhaps “name_only”
    5. Leave the Meta/Template text box empty.
    6. Click the “MLA Column” check box to make the field available in the Media/Assistant submenu table. You can also click the “Quick Edit” and “Bulk Edit” check boxes to make the field available in the Media/Assistant submenu table Quick Edit and Bulk Edit areas if that’s useful for you.
    7. In the “Existing Text” dropdown, select “Replace” to replace existing values or “Keep” to retain any existing values.
    8. In the “Format” dropdown list, select “Native”.
    9. In the “Option:” dropdown list, select “Text”.
    10. Click the “Delete NULL Values” checkbox.
    11. Leave the “Status” set to “Active”.
    12. Click the “Add Rule” button to save your work.

    Once you define the rule you can update existing pictures by applying 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 Custom Field metadata” link to run your rules on this item, then look at the “Custom Fields” meta 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 Custom Field metadata” button to run your rule on the selected items.
    • To map all of your items, stay on the Settings/Media Library Assistant Custom Fields tab and click the “Execute” rollover action for your custom rule. This may take a while.

    The first two methods will apply all active Custom Field rules to the selected item(s). This won’t be a problem if you have only the one rule, but the third method might be the best if you have other rules in place.

    You wrote “But the grid view is still not sortable.” Some time ago I investigated making the grid view sortable and discovered that the sort order was hard coded in the Media Manager Modal Window JavaScript code. I agree that it’s primitive/unfortunate.

    I am marking this topic resolved, but please update it if you have any problems or further questions regarding the custom field approach. Thanks for your interest in the plugin.

    Thread Starter cmyck

    (@cmyck)

    Wow, thank you so much, David! What an awesome plugin you have written.
    This worked like a charm.
    The problem still is, that the dialog you get when adding images to a gallery is in grid view. No sorting there. I wonder if one could hack the JS, by overloading that hard coded sort function…

    If I wanted to populate the Title field of an image with its File Name, would that also be possible with MLA?

    Plugin Author David Lingren

    (@dglingren)

    Thanks for the kind words and the good news about your progress.

    You asked “If I wanted to populate the Title field of an image with its File Name, would that also be possible with MLA?” You can use an IPTC/EXIF mapping rule for this purpose. Here is an earlier topic that outlines a solution:

    Mapping PDF fields

    The first part of that solution can be adapted to update many of the WordPress standard fields, e.g., Title. For your specific application simply change step 5. to be:

    5. In the “EXIF/Template Value” text box, enter template:([+file_name+]).

    Regarding the MMMW you wrote “I wonder if one could hack the JS, by overloading that hard coded sort function…” That code was a very early experiment of significant JavaScript coding using complex frameworks. The code has been described as “black voodoo” by a member of the WordPress core team. I have found it very challenging, although I admit my own JavaScript skills are lacking. If you do attempt it, I wish you the best of luck.

    Thread Starter cmyck

    (@cmyck)

    Thanks a lot, David!
    Truly awesome plugin.
    I took a look at the JS. It is beyond saving. 😀
    Wordpress needs a total rehaul of the media library. It is just unbelievably bad UX.

    Thread Starter cmyck

    (@cmyck)

    I just tried to populate the ALT Text field with the content of the caption field.
    I edited the existing ALT Text, IPTC Value = none, EXIF Value: ([+caption+]), Prioriy: EXIF, Existing Text: Replace, Status: Active
    It’s not working. I also don’t know, where to look up those field names.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your updates with the good news and the kind words.

    Regarding your caption issue, the [+caption+] substitution parameter is only available in the [mla_gallery] shortcode, since it is computed during gallery composition. That’s why it appears in the “Attachment-specific substitution parameters for the markup template Item part” section of the Documentation.

    You can use [+post_excerpt+] to achieve similar results, or any other values from the “Field-level data sources” of the Documentation. Those values are available for mapping rules as well as in the [mla_gallery] shortcode.

    If you have problems or further questions regarding the mapping rules post an update here and I will do what I can to help.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Media Libary oder by filename’ is closed to new replies.