adding rel attribute to image link in a node
I need to add a rel attribute to my image link. How can I do
  this?


You can add a data attribute to your link in l() function:

// your image
$image = array(
    'style_name' =&gt; 'the name of the image style',
    'path' =&gt; 'relative path to your image',
    'alt' =&gt; '',
    'title' =&gt; '',
    'attributes' =&gt; array('class' =&gt; array('some_class'))
);

// link elements
$text = theme('image_style', $image); // in your case it's an image
$path = 'link_url';
$options = array(
    'attributes' =&gt; array(
        'class' =&gt; array('some_link_class'), 
        'rel' =&gt; 'some_relation'
    ),
    'html' =&gt; true
);

$link =  l($text, $path, $options);


result:

&lt;a class="some_link_class" rel="some_relation" href="/your_site/link_url"&gt;
    &lt;img src="path to your image style" class="some_class" typeof="foaf:Image"&gt;
&lt;/a&gt;