首页 / 帖子
feeds 上傳多張圖片

各位好:小弟目前使用feeds 來實現文章批次上傳,文章要有多張圖片,但目前只能上傳一張,無法上傳多張。

想請問有人做過嗎?

feeds 欄位為

name:title

body:body

image:image

前csv 後drupal content type

我的csv,為

name,body,image

標題,內文,圖片.png|圖片.png



4个答案
AnnyO
发布于:2015-02-04 20:39

使用feeds_tamper模块可以实现,对图片那栏应用tamper plugin 'list - explode' 分割为数组。

这样就可以上传多张图片了。

发布于:2015-02-05 14:10

請問csv 要如何區別第一張跟第二張圖片?中間要用甚摸符號分開?


发布于:2015-02-11 11:23

图片字段若是设置成多个文件上传,需修改feeds代码先,默认不支持多个文件上传。

修改位置:feeds/mappers/file.inc文件

function file_feeds_set_target($source, $entity, $target, $value) {
  if (empty($value)) {
    return;
  }
  module_load_include('inc', 'file');
  // Make sure $value is an array of objects of type FeedsEnclosure.
  if (!is_array($value)) {
    $value = str_replace(', ', ',', $value); // 确保用户填写的分隔符有效,支持 ', ' 和 ',',即带空格和不带空格都可以
    $value = explode(', ', $value);
    //$value = array($value);
  }

如代码所示,如果我们在模板中填写:images/01.jpg, images/02.jpg, images/.... 这样,代码就会将这个$value根据我们要求的符号:', '来分割成数组,然后处理每个文件地址。


老葛
发布于:2015-02-11 11:37

使用feeds tamper即可,不需要hack 源代码。