0
Drupal 8에서 엔티티의 이미지 경로를 얻는 방법을 알아 내려고합니다. get() -> value는 그렇게 할 것이라고 생각했지만 값은 빈 문자열을 반환합니다. .Drupal 8 Image 필드 값
function getValueTest ($profile_id, $field)
{
$profile_storage = \Drupal::entityManager()->getStorage('profile');
$profile = $profile_storage->load($profile_id);
if ($profile != null)
{
if ($profile->hasField ($field))
{
return $profile->get ($field)->value;
}
}
return "No field" . $field;
}
두 필드 및 field_first_name field_mugshot 가지고 어떤 프로파일 ID (3)을 가정
난 시험 기능을 갖는다. 전화를 걸면 :
dpm ($this->getValueTest (3, 'field_first_name'));
dpm ($this->getValueTest (3, 'field_mugshot'));
첫 번째 호출은 메시지 영역에 첫 번째 이름을 올바르게 표시하지만 두 번째 호출은 빈 문자열을 제공합니다. 그 내용에 대한 처리를 할 수 있도록 이미지 경로가 필요합니다. 기업은 value() 메서드 필드 (일명 FID)의 값을 반환해야하기 때문에
$entity->get('field_image')->entity->getFileUri();
$entity->get('field_image')->entity->url();
이것은 필드 :
그게 정확히 내가 필요로하는 것을 얻습니다. 감사. – PhotoKevin