本文整理汇总了C#中Nop.Core.Domain.Catalog.Product.GetDefaultProductPicture方法的典型用法代码示例。如果您正苦于以下问题:C# Product.GetDefaultProductPicture方法的具体用法?C# Product.GetDefaultProductPicture怎么用?C# Product.GetDefaultProductPicture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nop.Core.Domain.Catalog.Product
的用法示例。
在下文中一共展示了Product.GetDefaultProductPicture方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareProductOverviewModel
protected ProductModel PrepareProductOverviewModel(Product product, bool preparePriceModel = true, bool preparePictureModel = true, int? productThumbPictureSize = null)
{
if (product == null)
throw new ArgumentNullException("product");
var model = product.ToModel();
//price
if (preparePriceModel)
{
model.ProductPrice = PrepareProductPriceModel(product);
}
//picture
if (preparePictureModel)
{
//If a size has been set in the view, we use it in priority
int pictureSize = productThumbPictureSize.HasValue ? productThumbPictureSize.Value : _mediaSetting.ProductThumbPictureSize;
//prepare picture model
var defaultProductPictureCacheKey = string.Format(ModelCacheEventConsumer.PRODUCT_DEFAULTPICTURE_MODEL_KEY, product.Id, pictureSize, true, _workContext.WorkingLanguage.Id, _webHelper.IsCurrentConnectionSecured());
model.DefaultPictureModel = _cacheManager.Get(defaultProductPictureCacheKey, () =>
{
var picture = product.GetDefaultProductPicture(_pictureService);
var pictureModel = new PictureModel()
{
ImageUrl = _pictureService.GetPictureUrl(picture, pictureSize),
FullSizeImageUrl = _pictureService.GetPictureUrl(picture),
Title = string.Format(_localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), model.Name),
AlternateText = string.Format(_localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), model.Name)
};
return pictureModel;
});
}
return model;
}
示例2: PrepareProductOverviewModel
protected ProductModel PrepareProductOverviewModel(Product product, bool preparePriceModel = true, bool preparePictureModel = true, int? productThumbPictureSize = null)
{
if (product == null)
throw new ArgumentNullException("product");
var model = product.ToModel();
//price
if (preparePriceModel)
{
model.ProductPrice = PrepareProductPriceModel(product);
}
//picture
if (preparePictureModel)
{
//If a size has been set in the view, we use it in priority
int pictureSize = productThumbPictureSize.HasValue ? productThumbPictureSize.Value : _mediaSetting.ProductThumbPictureSize;
var picture = product.GetDefaultProductPicture(_pictureService);
if (picture != null)
{
model.DefaultPictureModel.ImageUrl = _pictureService.GetPictureUrl(picture, pictureSize, true);
model.DefaultPictureModel.FullSizeImageUrl = _pictureService.GetPictureUrl(picture);
}
else
{
model.DefaultPictureModel.ImageUrl = _pictureService.GetDefaultPictureUrl(pictureSize);
model.DefaultPictureModel.FullSizeImageUrl = _pictureService.GetDefaultPictureUrl();
}
model.DefaultPictureModel.Title = string.Format(_localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), model.Name);
model.DefaultPictureModel.AlternateText = string.Format(_localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), model.Name);
}
return model;
}