Basically you need to add the XPM/SiteEdit markup yourself around that image, as you are using additional HTML to display your image (your img
element).
So you need something like:
<div>
<!-- Start Component Field: {"XPath" : "tcm:Content/custom:Content/custom:image[1]"} -->
<img src="@@Component.Fields.image@@" tridion:type="Multimedia" alt="image" />
</div>
But you can also generate it using the MarkComponentField
custom functions as mentioned on Tridion Practice
Then it would look like this in your DWT Template (the outcome will be the same as above):
<div>
@@MarkComponentField('image')@@
<img src="@@Component.Fields.image@@" tridion:type="Multimedia" alt="image" />
</div>
The rules for the comment style markup are in the documentation, and you can basically generate it for any type of field, as long as you make sure that there is a parent HTML element around it (in my example the div
tag). That element is what the border will follow, so if your HTML doesn't give that specific element the same size as the image (sometimes elements can have a size of 0), then it will be difficult to use/see the border.
Third option is to use the TCDL notification around your field, this will require you to have the Enable inline editing for content
TBB in your Component Template after the DWT TBB (similair to what you require when using @@RenderComponentField()@@
).
<tcdl:ComponentField name="image">
<img src="@@Component.Fields.image@@" tridion:type="Multimedia" alt="image" />
</tcdl:ComponentField>
Again this will also end up the same as the first example, but depending on what Default Field HTML Tag you have set in the Parameters of the Enable inline editing for content
TBB, you will get that HTML tag around your image (by default a span
tag).
Once you get the hang of it, you will notice that a lot more fields are editable in a lot more ways (you can think of editing a link which consists of a url and a title as two different fields, as long as you find a way to put the markup for both of those fields in a separate HTML element). Technically you should only generate this markup on your Staging website, as that is where you use XPM on, but since its an HTML comment, it shouldn't harm your design (if you need to generate extra markers with additional HTML for editing the url and title of a link separately, then that should only happen on Staging and not on Live of course).
Update
It has been brought to my attention that there is an overload available of @@RenderComponentField()@@
with three parameters, which can also give us the wanted result. So option number four reads:
@@RenderComponentField('image', 0, '<img src="${Component.Fields.image}" tridion:type="Multimedia" alt="image" />')@@
Update 2
In 2013 SP1 the RenderComponentField
method has been deprecated and is replaced by the following syntax:
@@FieldStartMarker('Component.Fields.image')@@
@@FieldValueStartMarker(0)@@
<img src="${Component.Fields.image}" tridion:type="Multimedia" alt="image" />
@@FieldValueEndMarker()@@
@@FieldEndMarker()@@