Advertisement
mariussm

PHP Test

Jun 24th, 2011
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. <?php
  2.  
  3. // Created by Mariussm
  4. // This is a filter I use for my Drupal site. Makes it quicker to insert pictures.
  5.  
  6. function _filter_marius($text) {
  7.         $text = preg_replace("/\{img:(left|right):(\d+):(\d+):(.*?)\}/","<img src=\"$4\" alt=\"\" style=\"width: $2px; height: $3px; float: $1;\">",$text);
  8.         $text = preg_replace("/\{img:(left|right):(.*?)\}/","<img src=\"$2\" alt=\"\" style=\"float: $1;\">",$text);
  9.         $text = preg_replace("/\{img:center:(\d+):(\d+):(.*?)\}/","<p><img style=\"display: block; margin: 0 auto; width: $1px; height: $2px;\" src=\"$3\" alt=\"\"></p>",$text);
  10.         $text = preg_replace("/\{img:center:(.*?)\}/","<p><img style=\"display: block; margin: 0 auto;\" src=\"$1\" alt=\"\"></p>",$text);
  11.         return $text;
  12. }
  13.  
  14. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement