in my livewire post show blade I did this if I create a post with a link the is not previewing in my show view page , I have tried to different URL still not working
public function mount (Post $post)
{
$this->post = $post;
preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $post->body, $matches);
$this->urlDetails = collect($matches[0])->map(function ($url) {
$embed = new Embed();
$info = $embed->get($url);
return ['info' => $info, 'title' => $info->title];
})->all();
}
but you need to dump this so that you can see the structure. Since you ask for matches on the body, what you will get is an array response, even if there is only one.
You then map over this array, again, creating an array.
@snapey i was able to get the title with instagram link , but the of the image isnt working
when i dd again
"info" => Embed\Adapters\Instagram\Extractor {#2001 ▶}
"title" => "Instagram on Instagram: ““If I could describe Gen Z in three words, they would be radical, inclusive and unapologetic.” Anya Dillard (@iamajdillard) is the foun ▶"
"image" => GuzzleHttp\Psr7\Uri {#1943 ▼
-scheme: "https"
-userInfo: ""
-host: "instagram.flos1-1.fna.fbcdn.net"
-port: null
-path: "/v/t51.2885-15/278181615_407640024524677_1513490039406748060_n.jpg"
-query: "stp=dst-jpg_e35_p1080x1080&_nc_ht=instagram.flos1-1.fna.fbcdn.net&_nc_cat=1&_nc_ohc=bjdIOXiQ-jEAX_jcODy&edm=AABBvjUBAAAA&ccb=7-4&oh=00_AT_w-DMTwgn0XkET-73qDtOKc ▶"