Drupal 7 Get image field path

后端 未结 5 1677
悲哀的现实
悲哀的现实 2021-01-30 18:06

I would like to get the image path of a field. I\'m in a node and I need the Url of image in order to put it as a background-image in inline css. I can\'t find the solution. Can

5条回答
  •  误落风尘
    2021-01-30 18:51

    To get just the path of an image from it's URI:

    file_create_url($node->field_image['und'][0]['uri']);

    More information on file_create_url() can be found here: http://api.drupal.org/api/drupal/includes%21file.inc/function/file_create_url/7

    To get the path of an image created using an image style from it's URI use:

    image_style_url($style, $node->field_image['und'][0]['uri']);

    More information on image_style_url() can be found here: http://api.drupal.org/api/drupal/modules!image!image.module/function/image_style_url/7

提交回复
热议问题