How to get category image by category id in nopcommerce

Viewed 27

how can I get category image by category id in nopcommerce?

I am working in CategoryNavigationModel page with @model CategoryNavigationModel Model.

2 Answers

For getting all properties of category model using this method:

var category = await _categoryService.GetCategoryByIdAsync(id);

For getting a picture URL with target Size:

var PictureUrl = await _pictureService.GetPictureUrlAsync(category.PictureId, targetSize: 200);

For getting a full-size picture URL:

var FullPictureUrl = await _pictureService.GetPictureUrlAsync(category.PictureId);

For getting All properties of a picture as Picture Model:

var picture = await _pictureService.GetPictureByIdAsync(category.PictureId);

You need to pass category picture id. You can get category image by :

var picture = await _pictureService.GetPictureByIdAsync(category.PictureId);
Related