2010-06-03 5 views
3

imagecache 생성 이미지의 경로와 크기를 얻기 위해 imagecache_create_path() 및 getimagesize()를 사용하고 있습니다. 그러나 이미지가 아직 존재하지 않는 페이지에 처음 액세스하면 imagecache_create_path가 이미지를 생성하지 않습니다. 파일의 경로를 얻을 수 및 생성 할 수있는 API 방식은imagecache_create_path & getimagesize를 사용하기 전에 Drupal imagecache로 이미지 생성

// we get the image path from a preset (always return the path even if the file doesn't exist) 
$small_image_path = imagecache_create_path('gallery_image_small', $image["filepath"]); 
// I get the image dimensions (only if the file exists already) 
$data_small = list($width, $height, $type, $image_attributes) = @getimagesize($small_image_path); 

있습니까 : 여기

코드인가? 즉, 브라우저에서 표시하지 않고 PHP에서 이미지 (사전 설정 사용)를 생성 할 수 있습니까?

사전

답변

8

확인 imagecache_build_derivative() 기능과 imagecache.module에서의 사용에 감사드립니다.

+0

훌륭한 작품 : (테스트되지 않은 코드 오타 및 기타 오류/과실 조심 주)

$presetname = 'gallery_image_small'; $preset = imagecache_preset_by_name($presetname); $src = $image["filepath"]; $dst = imagecache_create_path($presetname, $src); // Ensure existing derivative or try to create it on the fly if (file_exists($dst) || imagecache_build_derivative($preset['actions'], $src, $dst)) { // Do what you need to do with the image } 

을 : 귀하의 경우, 그것은과 같이 거의 작동합니다. 고맙습니다 :) – ozke

+0

Drupal 6.25에서 페이지로드시 imagecache ''을 '인쇄'하거나 이미로드중인 응답 내용에 imagecache ''이 있으면 이미지가 기본적으로 체계. – atwixtor