Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

IPictureService.cs

using Microsoft.AspNetCore.Http;
using Nop.Core;
using Nop.Core.Domain.Catalog;
using Nop.Core.Domain.Media;

namespace Nop.Services.Media;

/// 
/// Picture service interface
/// 
public partial interface IPictureService
{
    /// 
    /// Returns the file extension from mime type.
    /// 
    /// Mime type
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the file extension
    /// 
    Task GetFileExtensionFromMimeTypeAsync(string mimeType);

    /// 
    /// Gets the loaded picture binary depending on picture storage settings
    /// 
    /// Picture
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the picture binary
    /// 
    Task LoadPictureBinaryAsync(Picture picture);

    /// 
    /// Get picture SEO friendly name
    /// 
    /// Name
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the result
    /// 
    Task GetPictureSeNameAsync(string name);

    /// 
    /// Gets the default picture URL
    /// 
    /// The target picture size (longest side)
    /// Default picture type
    /// Store location URL; null to use determine the current store location automatically
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the picture URL
    /// 
    Task GetDefaultPictureUrlAsync(int targetSize = 0,
        PictureType defaultPictureType = PictureType.Entity,
        string storeLocation = null);

    /// 
    /// Get a picture URL
    /// 
    /// Picture identifier
    /// The target picture size (longest side)
    /// A value indicating whether the default picture is shown
    /// Store location URL; null to use determine the current store location automatically
    /// Default picture type
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the picture URL
    /// 
    Task GetPictureUrlAsync(int pictureId,
        int targetSize = 0,
        bool showDefaultPicture = true,
        string storeLocation = null,
        PictureType defaultPictureType = PictureType.Entity);

    /// 
    /// Get a picture URL
    /// 
    /// Reference instance of Picture
    /// The target picture size (longest side)
    /// A value indicating whether the default picture is shown
    /// Store location URL; null to use determine the current store location automatically
    /// Default picture type
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the picture URL
    /// 
    Task<(string Url, Picture Picture)> GetPictureUrlAsync(Picture picture,
        int targetSize = 0,
        bool showDefaultPicture = true,
        string storeLocation = null,
        PictureType defaultPictureType = PictureType.Entity);

    /// 
    /// Get a picture local path
    /// 
    /// Picture instance
    /// The target picture size (longest side)
    /// A value indicating whether the default picture is shown
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the 
    /// 
    Task GetThumbLocalPathAsync(Picture picture, int targetSize = 0, bool showDefaultPicture = true);

    /// 
    /// Gets a picture
    /// 
    /// Picture identifier
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the picture
    /// 
    Task GetPictureByIdAsync(int pictureId);

    /// 
    /// Deletes a picture
    /// 
    /// Picture
    /// A task that represents the asynchronous operation
    Task DeletePictureAsync(Picture picture);

    /// 
    /// Gets a collection of pictures
    /// 
    /// Virtual path
    /// Current page
    /// Items on each page
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the paged list of pictures
    /// 
    Task> GetPicturesAsync(string virtualPath = "", int pageIndex = 0, int pageSize = int.MaxValue);

    /// 
    /// Gets pictures by product identifier
    /// 
    /// Product identifier
    /// Number of records to return. 0 if you want to get all items
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the pictures
    /// 
    Task> GetPicturesByProductIdAsync(int productId, int recordsToReturn = 0);

    /// 
    /// Inserts a picture
    /// 
    /// The picture binary
    /// The picture MIME type
    /// The SEO filename
    /// "alt" attribute for "img" HTML element
    /// "title" attribute for "img" HTML element
    /// A value indicating whether the picture is new
    /// A value indicating whether to validated provided picture binary
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the picture
    /// 
    Task InsertPictureAsync(byte[] pictureBinary, string mimeType, string seoFilename,
        string altAttribute = null, string titleAttribute = null,
        bool isNew = true, bool validateBinary = true);

    /// 
    /// Inserts a picture
    /// 
    /// Form file
    /// File name which will be use if IFormFile.FileName not present
    /// Virtual path
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the picture
    /// 
    Task InsertPictureAsync(IFormFile formFile, string defaultFileName = "", string virtualPath = "");

    /// 
    /// Updates the picture
    /// 
    /// The picture identifier
    /// The picture binary
    /// The picture MIME type
    /// The SEO filename
    /// "alt" attribute for "img" HTML element
    /// "title" attribute for "img" HTML element
    /// A value indicating whether the picture is new
    /// A value indicating whether to validated provided picture binary
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the picture
    /// 
    Task UpdatePictureAsync(int pictureId, byte[] pictureBinary, string mimeType,
        string seoFilename, string altAttribute = null, string titleAttribute = null,
        bool isNew = true, bool validateBinary = true);

    /// 
    /// Updates the picture
    /// 
    /// The picture to update
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the picture
    /// 
    Task UpdatePictureAsync(Picture picture);

    /// 
    /// Updates a SEO filename of a picture
    /// 
    /// The picture identifier
    /// The SEO filename
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the picture
    /// 
    Task SetSeoFilenameAsync(int pictureId, string seoFilename);

    /// 
    /// Validates input picture dimensions
    /// 
    /// Picture binary
    /// MIME type
    /// Name of file
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the picture binary or throws an exception
    /// 
    Task ValidatePictureAsync(byte[] pictureBinary, string mimeType, string fileName);

    /// 
    /// Gets or sets a value indicating whether the images should be stored in data base.
    /// 
    /// A task that represents the asynchronous operation
    Task IsStoreInDbAsync();

    /// 
    /// Sets a value indicating whether the images should be stored in data base
    /// 
    /// A value indicating whether the images should be stored in data base
    /// A task that represents the asynchronous operation
    Task SetIsStoreInDbAsync(bool isStoreInDb);

    /// 
    /// Get product picture (for shopping cart and order details pages)
    /// 
    /// Product
    /// Attributes (in XML format)
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the picture
    /// 
    Task GetProductPictureAsync(Product product, string attributesXml);

    /// 
    /// Get product picture binary by picture identifier
    /// 
    /// The picture identifier
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the picture binary
    /// 
    Task GetPictureBinaryByPictureIdAsync(int pictureId);

    /// 
    /// Convert image from SVG format to PNG
    /// 
    /// Stream for SVG file
    /// A task that represents the asynchronous operation
    /// The task result contains the byte array
    Task ConvertSvgToPngAsync(Stream stream);

    /// 
    /// Get content type for picture by file extension
    /// 
    /// The file extension
    /// Picture's content type
    string GetPictureContentTypeByFileExtension(string fileExtension);
}