2012-04-05 2 views
1

다국어 사이트에서 Drupal 업로드 경로에 문제가 있습니다. 새로운 언어를 만들었고 이미지 원본에 백 슬래시가 없으므로 작동하지 않습니다.다국어 사이트에서 Drupal 업로드 경로

내 함수는 다음 코드를 사용합니다.

variable_get('file_public_path', drupal_get_path('theme', $theme) . '/uploads').'/'; 

다음 중 하나를 사용하면 작동합니다.

'/' . variable_get('file_public_path', drupal_get_path('theme', $theme) . '/uploads').'/'; 

일종의 추악한 해결책이며,이를 처리하는 좀 더 우아한 방법이있을 것입니다.

답변

1

코드 대신 공개 경로에 저장되는 이미지의 URL을 가져 오는 것은 다음과 같습니다. (올바른 파일 이름 "의 image.png"를 교체합니다.)

$image_url = file_create_url(variable_get('file_public_path', conf_path() . '/files') . '/image.png'); 

당신의 코드에서, 당신은 그렇지 않으면 경로가 서버 문서 디렉토리를 기준으로 간주되지 않습니다, 시작 부분에 슬래시를 사용해야합니다.
Drupal 사이트의 언어로 이탈리아어를 사용하도록 설정 한 경우 페이지의 URL은 http://example.com/it/page이고 사이트/default/files/image.png에 이미지가 저장된다고 가정합니다. 슬래시가 없으면 이미지 URL은 브라우저에서 http://example.com/it/sites/default/files/image.png으로 간주됩니다. 슬래시를 사용하면 이미지 URL은 브라우저에서 http://example.com/sites/default/files/image.png으로 간주됩니다.

"file_public_path"Drupal 변수의 기본값은 variable_get('file_public_path', conf_path() . '/files'이어야합니다. 이것이 system_file_system_settings()에 사용 된 기본값입니다.

$form['file_public_path'] = array(
    '#type' => 'textfield', 
    '#title' => t('Public file system path'), 
    '#default_value' => variable_get('file_public_path', conf_path() . '/files'), 
    '#maxlength' => 255, 
    '#description' => t('A local file system path where public files will be stored. This directory must exist and be writable by Drupal. This directory must be relative to the Drupal installation directory and be accessible over the web.'), 
    '#after_build' => array('system_check_directory'), 
); 
관련 문제