If you want to send HTML, send HTML. If you want to send an image, send the image. Remember, the src="" attribute of an HTML <img> tag is supposed to be a URL to an image, not the image itself.
In your case, the URL will need to be one that calls a script with a request for the appropriate image.
Yes; another script. Just one reason why binaries tend not to be stored in databases, particularly in web applications. There are others.