视觉作曲家根据自定义ID显示图像缩略图

时间:2018-08-11 22:54:32

标签: php wordpress

下面是可视化编辑器的功能,它显示参数

与我的情况下的图库快捷方式有关;我将显示图像

对应于变量中的标识符$ param ['param_name'] =='ids'

field $ param ['type'] =='attach_images'。

目前仅显示一幅带有无效src的图像:我无法循环播放

在ID图像上 result_images_from_ids

如何为变量分配$ param ['param_name'] =='ids'

浏览并显示图像的src吗?

    <?php 
protected function renderField( $param, $value ) {
    $param['vc_single_param_edit_holder_class'] = array(
        'wpb_el_type_' . $param['type'],
        'vc_wrapper-param-type-' . $param['type'],
        'vc_shortcode-param',
        'vc_column',
    );
    if ( ! empty( $param['param_holder_class'] ) ) {
        $param['vc_single_param_edit_holder_class'][] = $param['param_holder_class'];
    }
    $param = apply_filters( 'vc_single_param_edit', $param, $value );
    $output = '<div class="' . implode( ' ', $param['vc_single_param_edit_holder_class'] ) . '" data-vc-ui-element="panel-shortcode-param" data-vc-shortcode-param-name="' . esc_attr( $param['param_name'] ) . '" data-param_type="' . esc_attr( $param['type'] ) . '" data-param_settings="' . esc_attr( json_encode( $param ) ) . '">';
    $output .= ( isset( $param['heading'] ) ) ? '<div class="wpb_element_label">' . $param['heading'] . '</div>' : '';
    $output .= '<div class="edit_form_line">';
    if ( $param['param_name'] == 'ids' ){
        $output .= '<p>images ids</p>';

    }
     // boucle for images ids 
     if ($param['type'] == 'attach_images' ){
         $array_images_ids = explode(',', $images);

       foreach($array_images_ids as $id){
                $img = wp_get_attachment_image_src($id, 'thumbnail');
                $output .=' 
                <div class="gallery_widget_attached_images">
                <ul class="gallery_widget_attached_images_list ui-sortable">
                <li class="added ui-sortable-handle">
                    <img src="'.esc_url($img[0]). '">
                    <a href="#" class="vc_icon-remove"><i class="vc-composer-icon vc-c-icon-close"></i></a>
                </li>
                </ul></div>

                ';

        }

 }
    $value = apply_filters( 'vc_form_fields_render_field_' . $this->setting( 'base' ) . '_' . $param['param_name'] . '_param_value', $value, $param, $this->settings, $this->atts );
    $param = apply_filters( 'vc_form_fields_render_field_' . $this->setting( 'base' ) . '_' . $param['param_name'] . '_param', $param, $value, $this->settings, $this->atts );
    $output = apply_filters( 'vc_edit_form_fields_render_field_' . $param['type'] . '_before', $output );
    $output .= vc_do_shortcode_param_settings_field( $param['type'], $param, $value, $this->setting( 'base' ) );
    $output_after = '';
    if ( isset( $param['description'] ) ) {
        $output_after .= '<span class="vc_description vc_clearfix">' . $param['description'] . '</span>';
    }
    $output_after .= '</div></div>';
    $output .= apply_filters( 'vc_edit_form_fields_render_field_' . $param['type'] . '_after', $output_after );

    return apply_filters( 'vc_single_param_edit_holder_output', $output, $param, $value, $this->settings, $this->atts );
}
?>

0 个答案:

没有答案