* 我自己解决了......就像10分钟后一样。 *
$varbgimg = $row->_field_data['nid']['entity']->field_slideimage['und'][0]['uri'];
是我用过的......
<击> 希望可以有人帮帮我。如何访问'uri'=&gt; ? '公共://veglo8.jpg' 击>
<击>这是来自Drupal和Views模块。如果有人甚至可以帮助我实现我的最终目标,我会很感激......
我在视图中有一个名为 slideimage 的字段。我想在我的div中添加 style =“background-image:url(图像字段网址);”。试图重写输出,但它剥离了样式......
提前致谢。
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' =>
答案 0 :(得分:1)
您可以使用file_create_url
将public://...
转换为真实网址。
$real_url = file_create_url($img_src);
答案 1 :(得分:1)
我过去曾使用过pathinfo()
函数。
http://php.net/manual/en/function.pathinfo.php
您可以使用图片网址替换user-picture[0]['uri']
,以编程方式应用样式。我认为你甚至可以把整个公共:// url放在那里,它也可以正常工作。
THUMBNAIL_STYLE = 'thumbnail';
// now get the full image url from the uri and the style
$default_thumbnail = image_style_url($THUMBNAIL_STYLE, $user->picture[0]['uri']);