How can I re-write image tag URLs with FilterPlugin's SUBST macro?

Refer to FilterPlugin's SUBST macro documentation. The pattern argument is a regular expression designed to match and capture text. The format parameter is used to replace the matched pattern, and in doing so can access any captured text inside parenthesis in the pattern.

In the following example, we want to re-write <img> tags so that <img src="filename.png"/> becomes <src="/pub/Support/Faq60/filename.png">

%STARTSECTION{"test"}%
Original:
-----
%INCLUDE{"%TOPIC%Junk"}%
-----
Transformed:
-----
%SUBST{
  topic="%TOPIC%Junk"
  pattern="(<img[^>]*src=['\"])([^'\"]*)(['\"])"
  format="$1%ATTACHURLPATH%/$2$3"
  expand="off"
}%%ENDSECTION{"test"}%

Test

ALERT! This solution will include extraneous META lines until FilterPlugin's Tasks.Item11153 is fixed

Support.FAQForm edit

TopicClassification FrequentlyAskedQuestion
Subject Extension
Topic Summary Demonstrates usage of FilterPlugin's SUBST macro to re-write <img> tag URLs
Extension FilterPlugin
Interested Parties
Related Topics
Topic revision: r2 - 27 Dec 2011, ArthurClemens - This page was cached on 08 Apr 2017 - 04:27.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License