Drupal Feeds从图像服务导入图像

时间:2015-10-18 09:05:34

标签: drupal drupal-feeds

我正在使用Drupal 7和Feeds将图像字段导入到内容类型文章中,当图像网址是图像的直接链接时,它会起作用。

但链接到图片处理程序的图片:http://business.iafrica.com/apps/imageUtil/view/article/1008937/1/630x385/未导入。

我试过了:

  • 使用Feeds Tamper Module和Feeds Tamper PHP尝试更改图像名称,这个 导致无效的网址加载。
  • 要使用Field Image Grabber,但我有XML源,而不是HTML。

这是我的源Feed网址http://resource.thumbtribe.mobi/ds1.portal/portal/1/4/resource/view/maximized/9500187?format=atom_extern

和我的Image:URI xpath映射是:string(link [@rel =" enclosure"] / @ href)

1 个答案:

答案 0 :(得分:1)

我设法通过使用feed篡改模块和以下php片段来保存图像然后引用我服务器上的路径来解决这个问题。

$checkext = substr($field, -5);

if (strpos($checkext,'.') == false)
{
  $filename = str_replace(".","_",microtime(true)).".jpg";
  $output = "public://field/image/".$filename;
  file_put_contents($output, file_get_contents($field));
  return  $output;
}
else
{
  return $field;
}
相关问题