Good to hear from you again, and thanks for your question.
Removing the commas from the tags list reminded me of this earlier topic and the other topics I referenced there:
set title to be filename stripping characters
There have been several “clean up a value” topics over the years and I decided to make tasks like yours easier by adding a new format option value that can be used with any data substitution parameter. That removes the need for bits of PHP code to perform these simple changes. Here is a description of the new format option:
,str_replace(s,r) – Replace all occurrences of the “search” string (s) with the “replacement” string (r). If search and replacement are arrays, then str_replace()
takes a value from each array and uses them to search and replace on subject. If replace has fewer values than search, then an empty string is used for the rest of replacement values. If search is an array and replace is a string, then this replacement string is used for every value of search. You can find complete information on “search” and “replacement”, including examples, at: https://php.net/manual/en/function.str-replace.php.
?
To specify an array argument enclose the argument in braces ( “{” and “}” ) and separate elements with spaces. For example, ,str_replace( {',' '-'}, {' ' '_'} )
will change commas to spaces and dashes to underscores, while ,str_replace( {',' '-'}, ' ' )
will change both commas and dashes to spaces.
For your application the new substitution parameter would be:
[+terms:attachment_tag,str_replace( ',', '' )+]
That should remove the commas and leave one space between the tag values. You might also consider using the term slug instead of the term name, since you are using the values as class attributes:
[+terms:attachment_tag(slug),str_replace( ',', '' )+]
That will sanitize the values in a way that might work better for you.
I have uploaded a new MLA Development Version dated 20171109 that contains the new format option value. It would be great if you can install the Development Version and example plugin and do some testing of your own. To get the Development Version, follow the steps in this earlier topic:
PHP Warning on media upload with Polylang
I hope the new format option will give you the solution you need without resorting to PHP code. I will leave this topic unresolved until I hear back from you. Thanks for inspiring an MLA enhancement!