CoreFiles by mySites.guru
document.php43 lines, 1,238 bytes, from Joomla_6.1.2-Stable-Full_Package.zip
Raw History Compare with 6.1.1
md5
456cdbcf321de6c50f934b2ff68e34d9
sha1
533a4004b1a9f8f48242b36f547eb22033517bcf
sha256
8c86fa1519011fadde6f22431c14faecb4192616b465d7b08c4c8ad706cc06e6
<?php

/**
 * @package     Joomla.Plugin
 * @subpackage  Fields.Media
 *
 * @copyright   (C) 2026 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\Helper\MediaHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\Uri\Uri;

if (empty($file = $field->value) || empty($field->value['file'])) {
    return;
}
$fileUrl = MediaHelper::getCleanMediaFieldValue($field->value['file']);
// detect local file path
$isLocalFile = false;
if (empty((new Uri($fileUrl))->getHost())) {
    $fileUrl     = JPATH_SITE . DIRECTORY_SEPARATOR . $fileUrl;
    $isLocalFile = true;
}
if ($isLocalFile && !\is_file($fileUrl)) {
    return;
}

$class   = $fieldParams->get('css_class');
$options = [];

if ($class) {
    $options['class'] = $class;
}
$linkText = $field->value['linktext'] ?? Text::_('JLIB_FORM_FIELD_PARAM_ACCESSIBLEMEDIA_PARAMS_LINKTEXT_DEFAULT_VALUE');
$fileUrl  = $isLocalFile ? $field->value['file'] : $fileUrl;
if (str_contains($linkText, '{filename}')) {
    $linkText = str_replace('{filename}', basename($fileUrl), $linkText);
}
echo HTMLHelper::link($fileUrl, $linkText, $options);

The same content is in 27 releases, Joomla 6.1.0-beta2 to 6.2.1-rc1. See them all, or every version of this file.