Source for file ImgRequired.php

Documentation is available at ImgRequired.php

  1. <?php
  2.  
  3. // must be called POST validation
  4.  
  5. /**
  6.  * Transform that supplies default values for the src and alt attributes
  7.  * in img tags, as well as prevents the img tag from being removed
  8.  * because of a missing alt tag. This needs to be registered as both
  9.  * a pre and post attribute transform.
  10.  */
  11. {
  12.     
  13.     public function transform($attr$config$context{
  14.         
  15.         $src true;
  16.         if (!isset($attr['src'])) {
  17.             if ($config->get('Core''RemoveInvalidImg')) return $attr;
  18.             $attr['src'$config->get('Attr''DefaultInvalidImage');
  19.             $src false;
  20.         }
  21.         
  22.         if (!isset($attr['alt'])) {
  23.             if ($src{
  24.                 $attr['alt'basename($attr['src']);
  25.             else {
  26.                 $attr['alt'$config->get('Attr''DefaultInvalidImageAlt');
  27.             }
  28.         }
  29.         
  30.         return $attr;
  31.         
  32.     }
  33.     
  34. }

Documentation generated on Thu, 19 Jun 2008 18:49:37 -0400 by phpDocumentor 1.4.2