CoreFiles by mySites.guru
document.php43 lines, 1,237 bytes, from Joomla_6.1.0-beta1-Beta-Full_Package.zip
Raw History Compare with 6.0.0-beta3
md5
f9106dac087b9449e1ac96ae3c285702
sha1
af82cbf01e720484bbffa7e8eab9dd7efb24feef
sha256
fe65d5c92a4571f0ed29dbbf1de3c9ffbf201a9bd6f11b46cb31c6bd46978862
<?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\HTML\HTMLHelper;
use Joomla\CMS\Helper\MediaHelper;
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);

No other release has this exact content. See every version of this file.