Support » Plugin: Media Library Assistant » Replace MIME-type Icons in [mla_library] with Images

  • Resolved BriDanz


    Hi, I am attempting to have the [mla_gallery] display a group of documents (in this case, pdf’s) and have the icons replaced with a unique image for each document. I can add the image to the description of the document like this:
    <img src=”http://pwm-lsamuel-ws/wp-content/uploads/2014/04/circle4.png” alt=”” />
    But that adds the image below the icon, and I need to replace it.

    This is the current shortcode I have on my page:

    [mla_gallery post_mime_type=application/pdf post_parent=all size=icon link=file mla_style=”none” columns=4 mla_caption=”{+description+}” mla_image_alt=”{description}” mla_viewer=true]

    Any thoughts and help would be greatly appreciated.



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


    Thank you for this question and for posting the source code of your current shortcode; very helpful.

    I Would suggest that you create a custom field to hold the “unique image for each document“, leaving the description to its more traditional use. First, to define a custom field and make it available for editing:

    1. Navigate to the Settings/Media Library Assistant “Custom Fields” tab.
    2. Scroll down to the “Add a new Field and Mapping Rule” area.
    3. In the first text box, give your field a name, e.g., “PDF Thumbnail”.
    4. From the Data Source dropdown list, select “- None (select a value) -“. This default means the custom field will be filled manually, not by a data mapping rule.
    5. In the “Existing Text” dropdown list, select “Replace”.
    6. In the “Format” dropdown list, select “Native”.
    7. Click the “MLA Column” and “Quick Edit” check boxes to make the field available in the Media/Assistant submenu table and the Quick Edit area. Leave the “Bulk Edit” checkbox unchecked, since this field is unique for each PDF document.
    8. In the “Option:” dropdown list, select “Text”.
    9. Leave the “Delete NULL Values” checkbox unchecked.
    10. Click the “Add Field” button to save your work.

    Now you can go to the Media/Assistant submenu table and fill in the image data you want for your PDF documents, using either the “Quick Edit” rollover action or the “Edit” rollover action. You want to enter all of the attributes for your thumbnail images but not the HTML < img > tag itself, since you can’t put raw HTML in a custom field for [mla_gallery] display. For your example image, you would enter src="http://pwm-lsamuel-ws/wp-content/uploads/2014/04/circle4.png" alt="" in the field. You can also enter height and width attributes, etc, if you need them.

    Now you can define a custom markup template to use the custom field in your shortcode results:

    1. Navigate to the Settings/Media Library Assistant MLA Gallery tab.
    2. Scroll to the bottom of the screen to add a new template.
    3. Give it a name such as “pdfthumb”
    4. Copy the five sections from the default markup template to the corresponding section of your new template.
    5. In the “Item:” section, replace the [+link+] substitution parameter with < a href="[+link_url+]">< img [+custom:PDF Thumbnail+]>< /a> (removing the spaces before the a , img and the /).
    6. Scroll to the bottom and click “Save Changes” to save your work.

    Finally, modify your shortcode to use the new template:

    [mla_gallery post_mime_type=application/pdf post_parent=all link=file mla_style="none" mla_markup=pdfthumb columns=4 mla_caption="{+description+}" mla_image_alt="{description}"]

    I have added the mla_markup=pdfthumb parameter and removed the size=icon and mla_viewer=true parameters, since they do not apply to your template. I have left the mla_style="none" parameter; I assume you have some other source for styling the results.

    I hope that gets you started on creating PDF galleries with custom image thumbnails. I am marking this topic resolved, but please update it if you have any problems or further questions. Thanks again for a geat question and for your interest in the plugin.

    David, Thank you for the extremely thorough and helpful response. I will give this method a go and report back on any successes or challenges.

    Thanks again,


    David, Thanks for the detailed information.

    Thanks & Regards,

    Plugin Author David Lingren


    This is even more relevant after recent changes in the mla_viewer function! See this recent support topic for more information:

    mla_galery thumbnails are too small.

    Plugin Author David Lingren


    I have released MLA version 2.10, which includes a new implementation of the mla_viewer option. One of the new features is “Featured Image” support for non-image items. You can assign a Featured Image to, for example, a PDF document just as you would for a post or page. The Featured Image will be used to generate a thumbnail image for the document when used in an [mla_gallery] shortcode.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Replace MIME-type Icons in [mla_library] with Images’ is closed to new replies.