Learn how to embed services using their public URL using the laravel-embed package.

A client came to me with a new requirement for their website: to be able to embed content from multiple services (YouTube, Vimeo, Slideshare etc.). This is a fairly common requirement, particularly for embedding things like YouTube videos and it’s a problem I’ve solved multiple times.

Each time I’ve done it, my approach has usually been to ask the client to fill in a “Video ID” field in the CMS. I can then use this ID to generate the appropriate embed code for the view.

This is pretty straightforward from a technical standpoint, but it’s not ideal for a few reasons:

  1. It’s reliant on the client’s technical ability to extract things like a YouTube video id from a URL. Or worse, an ID from the embed code if the URL isn’t all that’s needed.
  2. It’s a waste of time for the client
  3. It’s error prone

Wouldn’t it be better if they could just put in the URL of the thing they want to embed?

Of course, but then it’s up to the application to perform the task of generating the embed code from the URL… That’s why I made laravel-embed.

#laravel #php #web-development #developer

Embedding Media by Its Public URL using laravel-embed
2.35 GEEK