imageapiのファイルのパス
Drupalのモジュールimageapiのメソッドを自作のモジュールで呼んでみた。
その際に.infoのdependencieにimageapiを加えると呼び出せるようになる。
そこで以下のimageapi_image_openメソッドの第一引数の$fileを与える必要がある。
function imageapi_image_open($file, $toolkit = false) { if (!$toolkit) { $toolkit = imageapi_default_toolkit(); } if ($toolkit) { $image = new stdClass(); $image->source = $file; $image->info = image_get_info($file); $image->toolkit = $toolkit; if ($image = call_user_func($image->toolkit .'_image_open', $image)) { return $image; } } watchdog('imageapi', 'ImageAPI failed to open %file with %toolkit', array('%file' => $file, '%toolkit' => $toolkit), WATCHDOG_WARNING); return false; }
この$fileだが、
sites/mysite.com/files/
のようにスラッシュ無しで、Drupalインストールディレクトリからの相対パスで呼び込まないとエラーが出る。
またデジカメ写真などをアップロードした場合、ティルダ"~"が"%7E"にエンコードされていてハマることがある。
以下のようなコードで回避が必要だ。
$img_path = str_replace("%7E", "~", $img_path); return $img_path;