2

I am trying to render an Image in Sitecore 7.2

I am using following markup but it is showing text only, images is not being displayed.

<div class="advisor-advertisement">
    some text here
    <sc:Image ID="Image1" runat="server" Field="Image" />
    <sc:FieldRenderer ID="FieldRenderer1" runat="server" FieldName="Image" />
    <sc:Link ID="lnkAd" runat="server" Field="Link">
        <sc:FieldRenderer ID="imgAd" runat="server" FieldName="Image" />
    </sc:Link>
</div>

enter image description here

but it is rendering text only. enter image description here

2
  • 2
    Ali, are you able to inspect your rendered page and post the markup that is being generated? Also, have you validated publishing status? And is your output in Preview mode or published mode? Aug 7, 2017 at 1:25
  • Also, what's the HTML it renders? Does it render the Link or not? if not, then I'm guessing either it's a publishing issue or a Data Source not set correctly issue. Aug 7, 2017 at 18:38

1 Answer 1

1

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 <sc:Image> and <sc:FieldRenderer> controls.

Publishing

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.

Common Circumstances

I most often get reports of issues like this when the an order of events similar to the following occurs:

  1. An author uploaded a new image to Sitecore, thus creating a new media item
  2. 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)
  3. 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.

1
  • this was important bit "Otherwise, you should also set the Item property of those <sc:Image> and <sc:FieldRenderer> controls."
    – Ali
    Aug 7, 2017 at 23:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.