douyao1856 2013-01-18 14:11
浏览 5
已采纳

访问数组和/或对象

*I solved it myself... like 10 minutes later. *

$varbgimg = $row->_field_data['nid']['entity']->field_slideimage['und'][0]['uri'];

Is what I used...

Hope someone can help me. How can I access 'uri' => 'public://veglo8.jpg'?

This is from Drupal and the Views module. If someone could maybe even help me with my ultimate goal, I would appreciate that...

I have a field in Views called slideimage. I want to add a style="background-image:url(image field URL);" to my div. Tried to rewrite the output but it strips the style...

Thanks in advance.

stdClass::__set_state(array(
   'nid' => '20',
   'node_title' => 'Test 1',
   'field_data_field_slideimage_node_entity_type' => 'node',
   'field_data_body_node_entity_type' => 'node',
   '_field_data' => 
 array (
   'nid' => 
   array (
    'entity_type' => 'node',
    'entity' => 
    stdClass::__set_state(array(
     'vid' => '20',
     'uid' => '1',
     'title' => 'Test 1',
     'log' => '',
     'status' => '1',
     'comment' => '1',
     'promote' => '0',
     'sticky' => '0',
     'nid' => '20',
     'type' => 'test',
     'language' => 'und',
     'created' => '1358336066',
     'changed' => '1358337923',
     'tnid' => '0',
     'translate' => '0',
     'revision_timestamp' => '1358337923',
     'revision_uid' => '1',
     'body' => 
    array (
      'und' => 
      array (
        0 => 
        array (
          'value' => 'Body text here',
          'summary' => '',
          'format' => 'filtered_html',
          'safe_value' => '
Body text here',
          'safe_summary' => '',
        ),
      ),
    ),
     'field_slideimage' => 
    array (
      'und' => 
      array (
        0 => 
        array (
          'fid' => '8',
          'alt' => '',
          'title' => '',
          'width' => '624',
          'height' => '390',
          'uid' => '1',
          'filename' => 'veglo8.jpg',
          'uri' => 'public://veglo8.jpg',
          'filemime' => 'image/jpeg',
          'filesize' => '27393',
          'status' => '1',
          'timestamp' => '1358336725',
          'rdf_mapping' => 
  • 写回答

2条回答 默认 最新

  • douzhuangxuan3268 2013-01-18 14:17
    关注

    You can use file_create_url to convert public://... to real world URLs.

    $real_url = file_create_url($img_src);

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?