Display Images from Database

Display Images from Database

  

Hello,

I have a DB table I'm using to store images. The table includes a binary attribute for the image and a filename. I have successfully implemented an upload and now I have multiple images stored in this database table.


I understand how to display an image from a database, however, I am looking for guidance on displaying a particular image. As it is with default database properties set the same image is being selected every time. Here are the properties i have configured for the image widget:


Type: Database

Filename: GetClientImagesByTenantId.List.Current.ClientImages.FileName

Cache: No Cache

Attribute: ClientImages.Image

Entity Identifier: GetClientImagesByTenantId.List.Current.ClientImages.Id

Hi Travis,

This could be caused by browser caching. Take a look at my post here.

Aurelio Santos wrote:

Hi Travis,

This could be caused by browser caching. Take a look at my post here.

Thank you, Aurelio. I think the problem is more that I don't know how to specify which image in the database should be displayed. All I know is how to set the properties, but how do i customize to say select a certain image filename or even a certain image id to be displayed on a certain page from the DB?


Travis,

You're gonna have to filter the aggregate that fetches the image from the database. I don't know what your particular business case is, so I can't tell you exactly how to do that. But usually, images are associated to some other entity. Let's use "Product" as an example. If you created a "ProductImage" entity to store product images, you'd have a "ProductId" attribute. If you then wanted to show an image from a specific product, you'd filter the aggregate that fetches the image by the ProductId value.

I hope this helps.