0

I have a smarty variable which holds the HTML content as value. Inside the HTML content there is an image. I have to extract the url of that image for resize purposes.

I know there is a way to parse it in php and assign to smarty variable. But I need to know whether there is any method in smarty like regex to get the url of the <img>tag from HTML.

example:

{$post_content|regex_replace:"/(<img>|<img [^>]*>|<\\/>)/":""}

This is the code to escape <img> tag alone. Likewise I need to get the url of the image from the $post_content variable.

vignesh
  • 512
  • 1
  • 6
  • 25

1 Answers1

0

smarty is just a template engine. not a different language.

so whatever you can do in php can also be done in smarty.

so use php dom parsers :)

check this

and check this

one says u cant use php function and other says, but what i say is yes you can use php functions before assigning it to the template engine.

Community
  • 1
  • 1
Vipin Jain
  • 1,382
  • 1
  • 10
  • 19
  • Dude! I'm aware that we can use php functions before assigning to smarty variable. But I need to find is there any easy way in smarty to minimize the codes! – vignesh Nov 21 '12 at 12:30