【问题标题】:Get src from attach_image in WPBakery / Visual Composer从 WPBakery / Visual Composer 中的 attach_image 获取 src
【发布时间】:2019-06-13 09:01:29
【问题描述】:

我定义了以下字段类型:

array(
  'type' => 'attach_image',
  'heading' => esc_html__("Add background image"),
  'param_name' => 'background_image',
  'description' => 'Add a background image to this section.',
  'value' => __(''),
)

并在变量中定义短代码参数

extract(
  shortcode_atts(
    array(
      'background_image'=> '',
    ), 
    $atts
  )
); 

我正在尝试将附加图像的srcalt 显示为背景图像:

<div class="hero" style="background-image:url(<?php echo $background_image; ?>);></div>

但是,background-image:url() 显示为空?

【问题讨论】:

    标签: php html visual-composer wpbakery


    【解决方案1】:
    $img = wp_get_attachment_image_src($para['background_image']);
    echo $img['0'];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-16
      • 1970-01-01
      • 2019-04-10
      • 1970-01-01
      • 2018-05-13
      • 1970-01-01
      • 2019-01-15
      • 1970-01-01
      相关资源
      最近更新 更多