I have a node that contains various fields. I am able to get the values of text fields but not an image field. Below is the relevant output of the node variable being dumped in the twig template:
'field_main_image' =>
object(Drupal\field\Entity\FieldConfig)[1312]
protected 'deleted' => boolean false
protected 'fieldStorage' => null
protected 'id' => string 'node.homepage.field_main_image' (length=30)
protected 'field_name' => string 'field_main_image' (length=16)
protected 'field_type' => string 'image' (length=5)
protected 'entity_type' => string 'node' (length=4)
protected 'bundle' => string 'homepage' (length=8)
protected 'label' => string 'Main image' (length=10)
protected 'description' => string '' (length=0)
protected 'settings' =>
array (size=12)
...
protected 'required' => boolean false
protected 'translatable' => boolean false
protected 'default_value' =>
array (size=0)
...
protected 'default_value_callback' => string '' (length=0)
protected 'itemDefinition' => null
protected 'constraints' =>
array (size=0)
...
protected 'originalId' => string 'node.homepage.field_main_image' (length=30)
protected 'status' => boolean true
protected 'uuid' => string 'f40a7a65-18a5-4ced-85b0-ab1cdc41b2f5' (length=36)
private 'isSyncing' (Drupal\Core\Config\Entity\ConfigEntityBase) => boolean false
private 'isUninstalling' (Drupal\Core\Config\Entity\ConfigEntityBase) => boolean false
protected 'langcode' => string 'en' (length=2)
protected 'third_party_settings' =>
array (size=0)
...
protected '_core' =>
array (size=0)
...
protected 'trustedData' => boolean false
protected 'entityTypeId' => string 'field_config' (length=12)
protected 'enforceIsNew' => null
protected 'typedData' => null
protected 'cacheContexts' =>
array (size=0)
...
protected 'cacheTags' =>
array (size=0)
...
protected 'cacheMaxAge' => int -1
protected '_serviceIds' =>
array (size=0)
...
protected 'dependencies' =>
array (size=2)
...
I have seen similar questions on SE, like this one Getting the image URL from a field_image on a node, but none of the answers have worked for me.
Thanks in advance for any responses.