I know I've seen a module that does this at some point in the past but can't seem to find it right now. In Drupal 8, I have a link field. I want to fetch that link's metadata so I can display the link's title / summary / image via a formatter (think of how facebook displays links). I don't remember if this worked server-side, storing the info in the drupal db or client-side via javascript (and for the prototype I'm putting together, I doesn't matter).

I'd appreciate any help before I decide to go and write it myself.

  • Here's a great answer to acheive what you want, stackoverflow.com/a/3711554/7576961. You can maybe create a custom field formatter that implements that code.
    – user72672
    Sep 9 '19 at 7:42

You can do a lot with Custom Formatters and Tokens, also check out Field Formatter if you need to wrap the link around an image field.

For most control create one yourself, there are different tutorials for that, start here: Create a custom field formatter

  • Of course but the heavy lifting is fetching the page and extracting the title, summary and image url from the metadata. Sep 8 '19 at 23:23
  • Ah, I misunderstood when you said link metadata, I thought you were talking about the link field content, but now it seems you mean the whole page metadata. Are you using the module drupal.org/project/metatag? Are you trying to create something like social media card for your content?
    – prkos
    Sep 8 '19 at 23:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.