I have finally figured out the way, how to use the Dynamic display block with Image attach (Image module).

First add the Image attach field to your news_items view.

Then modify your template.php and change the following parts:

function garland_preprocess_ddblock_cycle_block_content(&$vars)

// add slide_image variable 
          if (isset($result->image_attach_iids)) {
            // get node id
            $nid = $result->image_attach_iids[0];
            // get image id
            $fid = db_result(db_query("SELECT fid FROM {image} WHERE nid = %d AND image_size = 'preview'", $nid));
            // get path to image
            $filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $fid));  
            $slider_items[$key1]['slide_image'] = 
                '<img src="' . base_path() . $filepath . 
                '" alt="' . $result->node_title . 
                '"/>';         
          }

function garland_preprocess_ddblock_cycle_pager_content(&$vars)

// add pager_item_image variable
          if (isset($result->image_attach_iids)) {
            // get node id
            $nid = $result->image_attach_iids[0];
            // get image id
            $fid = db_result(db_query("SELECT fid FROM {image} WHERE nid = %d AND image_size = 'preview'", $nid));
            // get path to image
            $filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $fid));  
            $pager_items[$key1]['image'] = 
                '<img src="' . base_path() . $filepath . 
                '" alt="' . $result->node_title . 
                '"/>';         
          }

Hope this helps for some of you guys...

Comments

slampy’s picture

Status: Fixed » Closed (fixed)

As I was testing this script on my production site I realized that the preview image doesn't always exists. So replace 'preview' with '_original'.