Added thumbnails for pictures in media folder view.

--HG--
branch : 1.x
This commit is contained in:
Bertrand Le Roy
2012-08-12 18:02:02 -07:00
parent 7d29c140c0
commit 55127c80f6
6 changed files with 32 additions and 3 deletions

View File

@@ -252,7 +252,7 @@ namespace Orchard.Media.Controllers {
}
public ActionResult EditMedia(MediaItemEditViewModel model) {
model.PublicUrl = _mediaService.GetPublicUrl(Path.Combine(model.MediaPath, model.Name));
model.PublicUrl = _mediaService.GetMediaPublicUrl(model.MediaPath, model.Name);
return View(model);
}

View File

@@ -8,5 +8,6 @@ namespace Orchard.Media.Models {
public long Size { get; set; }
public string FolderName { get; set; }
public DateTime LastUpdated { get; set; }
public string MediaPath { get; set; }
}
}

View File

@@ -16,6 +16,14 @@ namespace Orchard.Media.Services {
/// <returns>The public path relative to the application url.</returns>
string GetPublicUrl(string relativePath);
/// <summary>
/// Returns the public URL for a media file.
/// </summary>
/// <param name="mediaPath">The relative path of the media folder containing the media.</param>
/// <param name="fileName">The media file name.</param>
/// <returns>The public URL for the media.</returns>
string GetMediaPublicUrl(string mediaPath, string fileName);
/// <summary>
/// Retrieves the media folders within a given relative path.
/// </summary>

View File

@@ -52,6 +52,16 @@ namespace Orchard.Media.Services {
return _storageProvider.GetPublicUrl(relativePath);
}
/// <summary>
/// Returns the public URL for a media file.
/// </summary>
/// <param name="mediaPath">The relative path of the media folder containing the media.</param>
/// <param name="fileName">The media file name.</param>
/// <returns>The public URL for the media.</returns>
public string GetMediaPublicUrl(string mediaPath, string fileName) {
return GetPublicUrl(Path.Combine(mediaPath, fileName));
}
/// <summary>
/// Retrieves the media folders within a given relative path.
/// </summary>
@@ -79,7 +89,8 @@ namespace Orchard.Media.Services {
Size = file.GetSize(),
LastUpdated = file.GetLastUpdated(),
Type = file.GetFileType(),
FolderName = relativePath
FolderName = relativePath,
MediaPath = GetMediaPublicUrl(relativePath, file.GetName())
}).ToList();
}

View File

@@ -10,3 +10,9 @@
max-height:640px;
max-width:640px;
}
.smallPreviewImage {
max-height:64px;
max-width:128px;
float: left;
margin-right: 16px;
}

View File

@@ -68,6 +68,9 @@
size = mediaFile.Size,
folderName = mediaFile.FolderName,
mediaPath = Model.MediaPath })
@if (Html.IsPicture(mediaFile.Name)) {
<img src="@mediaFile.MediaPath" class="smallPreviewImage" alt="@mediaFile.Name"/>
}
</td>
<td>@mediaFile.User</td>
<td>@mediaFile.LastUpdated</td>