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:
- Navigate to the Settings/Media Library Assistant “Custom Fields” tab.
- Scroll down to the “Add a new Field and Mapping Rule” area.
- In the first text box, give your field a name, e.g., “PDF Thumbnail”.
- 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.
- In the “Existing Text” dropdown list, select “Replace”.
- In the “Format” dropdown list, select “Native”.
- 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.
- In the “Option:” dropdown list, select “Text”.
- Leave the “Delete NULL Values” checkbox unchecked.
- 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="https://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:
- Navigate to the Settings/Media Library Assistant MLA Gallery tab.
- Scroll to the bottom of the screen to add a new template.
- Give it a name such as “pdfthumb”
- Copy the five sections from the default markup template to the corresponding section of your new template.
- 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 /
).
- 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.