| 1: | <?php
|
| 2: |
|
| 3: |
|
| 4: |
|
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: |
|
| 11: | class HTMLPurifier_AttrTransform_ImgRequired extends HTMLPurifier_AttrTransform
|
| 12: | {
|
| 13: |
|
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: |
|
| 20: | public function transform($attr, $config, $context)
|
| 21: | {
|
| 22: | $src = true;
|
| 23: | if (!isset($attr['src'])) {
|
| 24: | if ($config->get('Core.RemoveInvalidImg')) {
|
| 25: | return $attr;
|
| 26: | }
|
| 27: | $attr['src'] = $config->get('Attr.DefaultInvalidImage');
|
| 28: | $src = false;
|
| 29: | }
|
| 30: |
|
| 31: | if (!isset($attr['alt'])) {
|
| 32: | if ($src) {
|
| 33: | $alt = $config->get('Attr.DefaultImageAlt');
|
| 34: | if ($alt === null) {
|
| 35: | $attr['alt'] = basename($attr['src']);
|
| 36: | } else {
|
| 37: | $attr['alt'] = $alt;
|
| 38: | }
|
| 39: | } else {
|
| 40: | $attr['alt'] = $config->get('Attr.DefaultInvalidImageAlt');
|
| 41: | }
|
| 42: | }
|
| 43: | return $attr;
|
| 44: | }
|
| 45: | }
|
| 46: |
|
| 47: |
|
| 48: | |