Lightbox doesn't show images loaded by entity_metadata_wrapper There is a field collection in a content type, it's name is field_jeld. This field collection has an image field, it is field_image. I also defined an image style called book_mini. I need to load the images using lightbox, to do so I set the following image format in manage display of every display mode:



I have to load the images in the front page so I used entity metadata wrapper, this is my code:

$nid = "A NID GET FROM SOMEWHERE ELSE";
$node = node_load($nid);
$wrapper = entity_metadata_wrapper('node',$node);
$jelds = $wrapper-&gt;field_jeld-&gt;value();
foreach ($jelds as $jeld){
    $item_id = $jeld-&gt;item_id;
    $fc_wrapper = entity_metadata_wrapper('field_collection_item', $item_id);
    $photo_field = $fc_wrapper-&gt;field_image-&gt;value();
    $image = theme('image_style',
        array(
            'style_name' =&gt; 'book_mini',
            'path' =&gt; $photo_field['uri'],
        )
    );
    print $image;
}


This code prints the image in book_mini format very well but the problem is, when I click on it, it is not loaded by lightbox and no popup is shown, in fact the image is not a link. How do I can solve this problem?



UPDATE1

I also tried this

$nid = "A NID GET FROM SOMEWHERE ELSE";
$node = node_load($nid);
$wrapper = entity_metadata_wrapper('node',$node);
$jelds = $wrapper-&gt;field_jeld-&gt;value();
foreach ($jelds as $jeld){
    $item_id = $jeld-&gt;item_id;
    $fc_wrapper = entity_metadata_wrapper('field_collection_item', $item_id);
    $photo_field = $fc_wrapper-&gt;field_image-&gt;value();
    $image = theme('image_style',
        array(
            'style_name' =&gt; 'book_mini',
            'path' =&gt; $photo_field['uri'],
        )
    );
    $name = $photo_field['filename'];
    $url=  $base_url."/sites/default/files/image/".$name;
    print "&lt;a href='".$url."' rel='lightbox'&gt;".$image."&lt;/a&gt;";
}


I'm sure the $url points to the right file, after clicking the browser opens the lightbox but it doesn't show image, only white screen!



UPDATE2

The only solution I found is to use filed collection views and Views. I created a View called loadcover and selected field_jeld as a field. I also created a View of field collection views, called fc_jeld, and selected the required fields. This is the Formatter configuration of field_jeld :



Then using this code

print views_embed_view("loadcover","block",$nid);


it worked ! sounds the lighbox works with field collection only in the Views not the node!!!
In the lightbox configuration settings it allows you to define a certain class, so it popups whenever an image has that certain class. So all you have to do is to find a way to add a class to your image. 

Perhaps you could use the Image URL Formater module. Set your image field format to url. (So when it prints, it will print the image url instead of the actual picture)

then concatenate a string to add html to your code. 

print '&lt;img src="' . $image . '" class="lightbox"&gt;';