We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32473
    • 10 Posts
    I want to strip the image tags from a variabele.
    This to use it in a rollover javascript.

    I made 4 image TV’s.

    I my template is a javascript for the rollover funtction.
    The image string has to be stripped from the tags, so i can use it in the javascript.

    Example:
    <img src="assets/images/Amsterdam/ouwezijds/ouwezijds.jpg" id="tumbnail" />

    To:
    assets/images/Amsterdam/ouwezijds/ouwezijds.jpg

    I tried PHX extension striptags but stil not working.

    The javascript is in the HTML template of my page
    So it tried this [*afbeelding2:striptags*] and [+afbeelding2:striptags+]

    http://wiki.modxcms.com/index.php/PHx/CustomModifiers#phx:striptags

    Please can anybody help me out?
    I got stuck in this!!

    Wim
    the Netherlands

      • 16895
      • 87 Posts
      I modified this slightly to create a PHx snippet.

      Create a snippet called ’phx:graburl’, and stick this into it:
      <?php
      $output;
      // using preg_replace
      return preg_replace('/.*src=([\'"])((?:(?!\1).)*)\1.*/si','$2',$output);
      ?>


      Then, when you wish to output the image (say the TV is called img), you would do this:

      <img src="[*img:graburl*]" alt="" />