I have a node with a field called "field_paragraph" which is a paragraph reference. Referencing a paragraph type which has a field called "field_image"
I'm trying to get the url of the field_image in a custom module and so far i have this. But i don't seem to get it work.
use Drupal\paragraphs\Entity\Paragraph;
use Drupal\node\Entity\Node;
$node = Node::load($nid);
$paragraph_field = $node->get("field_paragraph")->getValue();
$paragraph = Paragraph::load($paragraph_field[0]['target_id']);
Here is where the problem occurs
$uri = $paragraph->field_image->entity->getFileUri();
The above returns nothing.
I used kint to print "$paragraph->field_image->entity" and it returns null. What I'm I doing wrong? I tried all answers I could find on here to no avail.
After getting the uri I think calling the below line would be enough.
$url = file_create_url($uri);
Question: How do I get the url of an image field in paragraphs programmatically?
target_id
to the image file.