Support » Plugin: Media Library Assistant » Custom Fields and HTML Tags

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

    (@ernstwg)

    So far I’ve found another solution. Thank you.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your post and for the update letting me know you’ve found a solution. It would be great to know more about your solution, but I’d like to respond to the original post in case other MLA users may find it useful.

    You wrote “I like to split it up and to store contextual links in Format in custom field/s“. In general you could take all or any part of the last part of your current template and create a separate rule that stores that part in one or more custom fields. Then you could just reference the custom field(s) in the code that is “currently operational“.

    The only problem I can think of is that you do not have direct control of the order in which the mapping rules are executed. If your “currently operational” portion is mapped before the “contextual links” portion you will not get the results you seek.

    The current MLA version does not have any way to explicitly specify the order in which rules are applied; I will think about a possible way to add such a feature. For your specific case, the rules for standard fields such as Description are executed before rules for custom fields, so it’s a problem.

    I would be interested in the other solution you found and your thoughts on the solution I outlined above. Thanks for any remarks you’d like to make and for your sustained interest in the plugin.

    Thread Starter ernstwg

    (@ernstwg)

    I played around a little bit earlier with custom fields, to get certain information at the right place in the right time. Similar to your solution. I came to the point, that I could not get the html tags <a href= to work. All Html stuff seemed to be removed from the Custom field.

    My solution bypasses these issues. I have created a page Single Image. Calling this page I transfer the attachment_id, post_id as a URL parameter. In this situation I can control everyting via MLA gallery shortcodes and particurlary the mla_markup. Now I have everything visible for the user in a more or less structured way.

    The description contains today Items like ALL_Custom All_IPTC and so on. In the end I don’t know wether this is still important? For SEO, … have a look at

    Thank you.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for the additional information. I had a closer look at the “custom fields” part of your code and noticed that they contain references to the [+site_url+] substitution parameter, e.g.:

    <a title="Beitrag: [+parent_title+]" href="[+site_url+]/?page_id=[+parent+]">Beitrag: [+parent_title+]</a>
    

    In the current MLA version this parameter is only available in the [mla_gallery] shortcode. It cannot be used in a Custom Fields or IPTC/EXIF mapping rule, and that may be why you “could not get the html tags <a href= to work.

    I have uploaded a new MLA Development Version dated 20201016 that adds three new fields to the mapping rules Data Sources. They are site_url, base_url and base_dir. The last two give the location of the uploads directory.

    Thank you for calling my attention to this oversight and inspiring an MLA improvement.

    Thread Starter ernstwg

    (@ernstwg)

    Hi David. I did a quick test with the new development version.
    I created a custom field ‘ewg_att_test’ and assigned the following input via the iptc/exif mapping

    template:<a href="[+site_url+]">Test 1</a><br><a href="[+base_url+]">Test 2</a><br><a href="[+base_dir+]">Test 3</a>

    For display within the description field I used
    [+custom:ewg_att_test+] and [+site_url+]<br>[+base_url+]<br>[+base_dir+]<br> the output is a string.
    output is

    custom:ewg_att_test Test 1Test 2Test 3
    https://ernst-wilhelm-grueter.de
    https://ernst-wilhelm-grueter.de/wp-content/uploads
    /homepages/16/d663833562/htdocs/clickandbuilds/Geschichten/wp-content/uploads

    What am I doing wrong?

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your testing, your results and your patience in awaiting my reply. I have finally had a chance to do some testing and refresh my memory about the handling of HTML in shortcode parameters.

    I’m not sure exactly how to replicate your “display within the description field” but I ran some tests using [mla_gallery mla_caption='{+custom:ewg_att_test+}]. I also set up a mapping rule to generate the ewg_att_test values for my attachments.

    I verified that the mapping rule is working properly and storing the HTML markup in the custom field. The gallery display, however, stripped out the HTML and gave the results you documented.

    The cause is some code in MLA that “sanitizes” the custom field value before display, which is stripping out the HTML. The fix is simple; add ,raw to the parameter, i.e.:

    [mla_gallery mla_caption='{+custom:ewg_att_test,raw+}]
    

    The ,raw format modifier bypasses the sanitize operation and gets the result you want. I hope this fix works in your application.

    Thread Starter ernstwg

    (@ernstwg)

    Hi David. It took some time to come back to this, my apologies for this. Your solution works fine, great. 🙂

    • This reply was modified 3 years, 4 months ago by ernstwg.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Custom Fields and HTML Tags’ is closed to new replies.