Managing images for custom modules

Ashutosh Pandey asked on December 11, 2018 08:44

Hi, I am new to kentico and created a custom module for uploading data to module classes from Excel. I want to store image in some folder and upload only image name.

Where should I upload my images? What would be the URL of that image to display?

Example:

Image uploaded at: /files/images/test.jpg

In my HTML: <img src='/files/images/<%# Eval("image_name") %>'/>

Thanks

Correct Answer

Eric Dugre answered on December 27, 2018 20:04

If the images should always be present if the module and/or its data is exported or otherwise synchronized, I would recommend storing them in /App_Data/CMSModules/[module code name]. This folder is included in module export packages automatically.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Suneel Jhangiani answered on December 11, 2018 12:45

If the images are going to be uploaded then I would recommend using a Media Library. This way you get the benefit of Web Farm synchronization out of the box. It will also allow you to take advantage of other storage providers allowing your images to reside in either an Amazon bucket or Azure blob. Should be relatively easy to allow the user to upload the image and store the MediaLibrary FileGUID in a table within your custom module so that it can be easily retrieved. Once you have added the image to the media library it is simple to access using the media library page handler.

If you are generating the images from other data, then it doesn't really matter where you decide to store the files, but I would suggest putting the files in a folder under the 'SiteName' folder. As the images are generated you shouldn't have to worry about Web farm synchronization since the server should generated the image. The easiest way is to create a Custom Page Handler (ie. GetMyImage.aspx), which takes an ID from the querystring or url (depending on whether you use webforms or MVC), the handler then checks a known location for the image and if it doesn't exist generates it, finally once generated it sends it to the user.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.