Пример #1
0
    /// <summary>
    /// Returns the relative URL of the specifier asset path with optional resizing parameters.
    /// </summary>
    public static string AssetUrl(this IOrchardHelper orchardHelper, string assetPath, int?width = null, int?height = null, ResizeMode resizeMode = ResizeMode.Undefined)
    {
        var mediaFileStore = orchardHelper.HttpContext.RequestServices.GetService <IMediaFileStore>();

        if (mediaFileStore == null)
        {
            return(assetPath);
        }

        var resolvedAssetPath = mediaFileStore.MapPathToPublicUrl(assetPath);

        return(orchardHelper.ImageResizeUrl(resolvedAssetPath, width, height, resizeMode));
    }
Пример #2
0
    /// <summary>
    /// Returns the relative URL of the specified asset path with optional resizing parameters.
    /// </summary>
    public static string AssetUrl(this IOrchardHelper orchardHelper, string assetPath, int?width = null, int?height = null, ResizeMode resizeMode = ResizeMode.Undefined, bool appendVersion = false, int?quality = null, Format format = Format.Undefined, Anchor anchor = null, string bgcolor = null)
    {
        var mediaFileStore = orchardHelper.HttpContext.RequestServices.GetService <IMediaFileStore>();

        if (mediaFileStore == null)
        {
            return(assetPath);
        }

        var resolvedAssetPath = mediaFileStore.MapPathToPublicUrl(assetPath);

        if (appendVersion)
        {
            var fileVersionProvider = orchardHelper.HttpContext.RequestServices.GetService <IFileVersionProvider>();

            resolvedAssetPath = fileVersionProvider.AddFileVersionToPath(orchardHelper.HttpContext.Request.PathBase, resolvedAssetPath);
        }

        return(orchardHelper.ImageResizeUrl(resolvedAssetPath, width, height, resizeMode, quality, format, anchor, bgcolor));
    }