Good day!

There is a site on Drupal 7.3 on which products are displayed, for example

The node has a main picture and secondary pictures (below).

According to the statement of work, it is required that fancyBox work not only on the pictures below, but also on the "main" picture of the node. The material type “Product” with the standard field “Image” (field_image, field format fancybox, field multi-picture) was created in the admin, but picking in its settings does not allow the main picture to also acquire a fanbox.

In the template code, I see the following, in which the clue seems to me:

a) for a picture that does not increase by clicking the php-code:

print theme('image_style', array('style_name' => '250x350', 'path' => $content['field_image']['#items'][0]['uri'])); 

b) for the block of pictures, which increase:

 print render($content['field_image']); 

The problem is how to pull out of this field_image a single picture with the same properties of the FB as the whole block and display it correctly. I conjured in different ways, I tried to look with var_dump what was happening in these arrays, to no avail (

    1 answer 1

    You have a deadline:

     print theme('image_style', array('style_name' => '250x350', 'path' => $content['field_image']['#items'][0]['uri'])); 

    displays just a picture.

    You need a link to it with the fancybox class in order for fancyBox to work.

     "<a href=".$content['field_image']['#items'][0]['uri']." class ='fancybox'>".print theme('image_style', array('style_name' => '250x350', 'path' => $content['field_image']['#items'][0]['uri'])) ."</a>"; 

    This will display the preview as a link to the main image.