Your code looks correct, so long as the
Sitecore.Context.Item is the item that you took a screenshot of in the experience editor. Otherwise, you should also set the
Item preoperty of those
The first thing that you should look at is publishing, like @JayS mentioned in his comment. More specifically, in addition to making sure that the item that you took the screenshot of is published, you also need to make sure that the media item, itself, is published. By the same token, make sure that the media item is not an orphan in the web database by making sure that the media item's ancestors are published. If you can see the media item in the web database then its ancestors are inherently published.
I most often get reports of issues like this when the an order of events similar to the following occurs:
- An author uploaded a new image to Sitecore, thus creating a new media item
- Author added a reference to the new media item (i.e. set an image field to point at the new media item) from another item, Foo, (usually a page item, but sometimes a data source)
- Author published the Foo item.
See the mistake? The author never actually published the media item, so it never appeared on the page.
Other Things to Try
If none of the above solve the issue, then try publishing the entire content tree. If that still doesn't fix the issue, post the rendered markup for the specific section of the page and, if the image tag is rendered, let us know if the image URL leads to a 404.