Getting the image URL from a field_image on a node and view without any error.
Following error is get URI in view
if (!$spec_paragraph_result->get('field_og_image')->isEmpty()) {
$uri = $spec_paragraph_result->get('field_og_image')->entity->getFileUri();
$paragraph[$title]['image'] = file_create_url($uri);
}
else {
$paragraph[$title]['image'] = "";
}
following code show on using node URI in the node for the show in twig file please check following code.
function budfactory_preprocess_node(&$variables) {
$node = $variables['node'];
$node_type=$variables['node']->getType();
if (($node_type == 'artist_line_up') && (!$node->field_page_back_ground_image->isEmpty()))
{
$_SESSION['bg_image'] = file_create_url($node->field_page_back_ground_image->entity->getFileUri());
}
else{
$_SESSION['bg_image'] = file_create_url("");
}
}
No comments:
Post a Comment