I've just started learning how to use Drupal 7. I made a new content type that will be displayed as a feed in my front page. All the data I need are being fetched and displayed correctly except for the image, whose url is always missing the actual file. I have another feed in my front page that uses the default article content type and all the images display properly.
The code I used for both is essentially the same, the only difference being the content type being retrieved.
This set worked:
$query = db_select('node', 'n');
$query->fields('n', array('nid', 'title'))
->condition('n.type', 'article')
->leftJoin('field_data_body', 'u', 'u.entity_id = n.nid');
$query->addField('u', 'body_summary');
$query->orderBy("nid", "desc");
$query->range(0, 3);
$result = $query->execute();
while($row = $result->fetchAssoc()) {
$nid = $row['nid'];
$node = node_load($nid);
echo theme('image_style', array('style_name' => 'home-article-summary', 'path' => ($node->field_image['und'][0]['uri'])));
}
This didn't:
$query = db_select('node', 'n');
$query->fields('n', array('nid', 'title'))
->condition('n.type', 'news') //the only difference between the two is this line
->leftJoin('field_data_body', 'u', 'u.entity_id = n.nid');
$query->addField('u', 'body_summary');
$query->orderBy("nid", "desc");
$query->range(0, 3);
$result = $query->execute();
while($row = $result->fetchAssoc()) {
$nid = $row['nid'];
$node = node_load($nid);
echo theme('image_style', array('style_name' => 'home-article-summary', 'path' => ($node->field_image['und'][0]['uri'])));
}
I tried making the settings of the content type I created the same as the ones for article throught Structure->Content Types but nothing happened. What am I missing? Thank you.
edit: Upon inspection, I couldn't find a resized version of the image I uploaded for my custom content type. I'm assuming this means no resizing ever actually happened hence why the script didn't return a file. I still don't get why that happened.
edit the second: never mind. I found the problem. it's all working fine now. was just using the wrong variable.