Back to Version class

Method getMediaVersion

public string
getMediaVersion
()
Gets a media version which is used to append to Joomla core media files.
Returns
  • string The media version.
Since
  • 3.2
Class: Version
Project: Joomla

Method getMediaVersion - Source code

/**
 * Gets a media version which is used to append to Joomla core media files.
 *
 * This media version is used to append to Joomla core media in order to trick browsers into
 * reloading the CSS and JavaScript, because they think the files are renewed.
 * The media version is renewed after Joomla core update, install, discover_install and uninstallation.
 *
 * @return  string  The media version.
 *
 * @since   3.2
 */
public function getMediaVersion() : string
{
    // Load the media version and cache it for future use
    static $mediaVersion = null;
    if ($mediaVersion === null) {
        // Get the joomla library params and the media version
        $mediaVersion = LibraryHelper::getParams('joomla')->get('mediaversion', '');
        // Refresh assets in debug mode or when the media version is not set
        if (JDEBUG || empty($mediaVersion)) {
            $mediaVersion = $this->generateMediaVersion();
            $this->setMediaVersion($mediaVersion);
        }
    }
    return $mediaVersion;
}