【问题标题】:How to render image inside a form in drupal如何在drupal中的表单内渲染图像
【发布时间】:2017-08-24 03:07:03
【问题描述】:

我尝试在表单内渲染图像,但仍然没有渲染任何内容

这是自定义模块

$image_options = array(
    'path' => 'http://novelplanet.com/Content/images/noImage.jpg', 
    'alt' => 'Test alt',
    'title' => 'Test title',
    'width' => '50%',
    'height' => '50%',
    'attributes' => array('class' => 'image', 'id' => 'my-img'),
    );


    $image = theme('image', $image_options);

    $form['y']['image_div'] = array(
      '#prefix' => '<div class="image">',
      '#suffix' => '</div>',
      '#markup' => $image,
    );

在我的 tpl 中

<?php print drupal_render($form['y']['image_div']); ?>

如何在 form.inc drupal 6 中渲染图像

【问题讨论】:

    标签: drupal drupal-7 drupal-6


    【解决方案1】:

    使用主题方法如下:

    theme('image', $path, $alt = '', $title = '', $attributes = NULL, 
           $getsize = TRUE);
    

    你也可以使用

    theme('imagecache', $presetname, $path, $alt = '', $title = '',
           $attributes = NULL, $getsize = TRUE);
    

    如果您使用 ImageCache 模块。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多