What is the history of the project? Was it upgraded or deployed some time ago? Are you using workflows? If yes, where are you storing the files? File system or database?
Isn't it possible that you are missing the files version history, in case you are storing files on the file system?
Check whether you have the binary data available here: *\CMS\App_Data\VersionHistory\Attachments* if not, you can copy them from the original project backups, if you still have them.
Another cause could be that for some reason the site's code name was changed - this means when storing file on file system, the site's folder name does not match the actual site's code name.
Another option is to re-upload the images to start new version history.
f the backups are no longer available, and the content of the \CMS\App_Data\VersionHistory\Attachments\ cannot be restored, you can fix the AttachmentHistory objects using the following script, which will copy the AttachmentBinary from the latest published version and re-create the physical files. The old images will be lost, but at least you can keep all the history and this way you can fix all the images in the system at once:
public void FixAttachmentHistories()
{
// Get the list of all attachment, load only necessary columns for good performance
var allAttachments = AttachmentInfoProvider.GetAttachments()
.Columns("AttachmentID", "AttachmentDocumentID", "AttachmentGUID");
foreach (var attachment in allAttachments)
{
// Get all history entries for this attachment
var allHistory = AttachmentHistoryInfoProvider.GetAttachmentHistories()
.WhereEquals("AttachmentGUID", attachment.AttachmentGUID);
foreach (var history in allHistory)
{
// Check if the binary is missing
if (history.AttachmentBinary == null)
{
// Let's copy the binary from the published version
DocumentAttachment attachmentWithBinary = (DocumentAttachment)AttachmentInfoProvider.GetAttachmentInfo(attachment.AttachmentID, true);
var data = AttachmentBinaryHelper.GetAttachmentBinary(attachmentWithBinary);
history.AttachmentBinary = data;
history.Update();
}
}
}
}
P.S.: To render and display images, you can use one of the available transformation methods. For example - <%# GetImage("ImageFieldName") %>
anmd it has also overloads with size parameters.