value == '') { return; } $data = json_decode($field->value); if (!$data) { $data = (object) array('src' => $field->value, 'alt' => ''); } $class = (string) $fieldParams->get('media_class', ''); $type = (string) $fieldParams->get('mediatype', 'images'); $text = (string) $fieldParams->get('media_description', ''); if ($class) { $class = ' class="' . htmlentities($class, ENT_COMPAT, 'UTF-8', true) . '"'; } if ($text) { $text = htmlentities($text, ENT_COMPAT, 'UTF-8', true); } $value = (array) $data->src; $buffer = ''; $element = '%s'; if ($type !== "images") { $element = '%s'; } else { $text = $data->alt; } foreach ($value as $path) { if (!$path) { continue; } // remove some common characters $path = preg_replace('#[\+\\\?\#%&<>"\'=\[\]\{\},;@\^\(\)£€$]#', '', $path); // trim $path = trim($path); // check for valid path after clean if (!$path) { continue; } // clean path $path = JPath::clean($path); // create full path $fullpath = JPATH_SITE . '/' . trim($path, '/'); // check path is valid if (!is_file($fullpath)) { continue; } // set text as basename if not an image if (!$text && $type !== "images") { $text = basename($path); } $buffer .= sprintf($element, htmlentities($path, ENT_COMPAT, 'UTF-8', true), $class, $text ); } echo $buffer;