Fetch Image Thumbnail by Youtube Video Url Using PHP
All Articles Development

Fetch Image Thumbnail by Youtube Video Url Using PHP

Softhuge Technologies
Admin Softhuge
Verified Contributor
August 01, 2022 2 min read 2,499 views
Share:

Thumbnails are used for preview a single or group of media entities in a single explorer window. Youtube automatically generates (at least) three thumbnails and one image preview for every uploaded video, and you can easily get to them once you know how.

You Need followings to get thumbnail from youtube :

  • Html Form Design
  • Youtube Video Link OR Url (Want to fetch the thumbnail)
  • A Small Or Easy PHP Script

Here we have A simple design of form which ask youtube link and after pressing submit button, thumbnail is shown in img tag below the form. So let's start first of all we design simple form for submitting youtube video URL


  
  



Now we have to write PHP code in starting of this page in PHP tag. We have to launch localhost server or live hosting server. if you don't know, how to setup and run localhost server on your own Computer. See our another article on How to setup php webserver on local system.Â

 if(isset($_POST["get_thumbnail"]))
{
  $url = $_POST["url"];
  preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match);
  $youtube_id = $match[1];
  $img = "https://img.youtube.com/vi/".$youtube_id."/0.jpg";
}else{ $video_id = ""; }


Here Details of some of function of code

Preg_match is used to extract video id from the given youtube url. and

Link in $img = "https://img.youtube.com/vi/"; => this link is where every video thumbnail is stored, we can access our thumbnail by sending video id in link. when you enter a link in form and submit, then video's thumnail is shows in img tag.



Softhuge Technologies

Admin Softhuge

Verified Contributor
Software Engineering & Cloud Infrastructure Architecture

Building resilient high-performance digital products at Softhuge Technologies. Specializing in Flutter mobile development, Laravel SaaS, and cloud scale systems.

Explore More

Recommended Engineering Logs

Browse all publications
Google shares lose more than $100 billion after Bard AI failed to answer in ad
2 min read
Feb 12, 2023 Tech News

Google shares lose more than $100 billion after Bard AI failed to answer in ad

Bard is Google artificial intelligence chatbot. It will work exactly like ChatGPT, that is, users will be able to use the chatbot through conversation.Bard is based on the Language Model for Dialogue Application (LaMDA). LaMDA is a conversational chatbot just like ChatGPT but Google has kept it in limited testing. In addition to the indigenous development of Bard, Google recently invested $300 million in the AI start-up Anthropic. The recent mass layoffs at Microsoft and Alphabet also fuelled concerns that the leading tech companies are going to shed extra costs in a bid to invest more in AI technologies.Google's parent company, Alphabet, lost $100 billion in market value on Wednesday after its new AI chatbot produced a error in its first demo. Prabhakar Raghavan presented Bard on Wednesday as the future of the company, telling audience members that by using generative AI. He shared some fresh examples of its new conversational technology Bard in a livestreamed event in Paris on Wednesday. Bard is Google’s competitor to OpenAI’s ChatGPT AI. Google's live-streamed presentation on Wednesday morning did not include details about how and when it would integrate Bard into its core search function. Bard's error was discovered just before the presentation by Google, based in Mountain View, California. Reuters pointed out an error in Google's advertisement hours before Bard’s launch event in Paris.Bard is prompted with the question, "What new discoveries from the James Webb Space Telescope can I tell my 9-year old about?". The chatbot responds with a few bullet points, including the claim that the telescope took the very first pictures of "exoplanets," or planets outside of earth's solar system. Shares of Alphabet plunged as much as 9%. Alphabet’s stock, which had lost 40 per cent in value last year, has rallied 15 per cent since the beginning of 2023. Bard is an experimental conversational AI service, powered by LaMDA. Built using our large language models and drawing on information from the web, it’s a launchpad for curiosity and can help simplify complex topics ? https://t.co/fSp531xKy3 pic.twitter.com/JecHXVmt8l— Google (@Google) February 6, 2023 In a Monday blog post, CEO Sundar Pichai said Bard will be available exclusively to "trusted testers" before releasing the engine publicly in the coming weeks.

Read Technical Log
What is ChatGPT and Why banned in Schools And Universities
2 min read
Jan 29, 2023 Tech News

What is ChatGPT and Why banned in Schools And Universities

ChatGPT is a chatbot launched by OpenAI in November 2022. It has a remarkable ability to interact in conversational dialogue form and provide responses that can appear surprisingly human. ChatGPT can write emails, essays, poetry, answer questions, or make codes. Schools and institutions in the India, US and elsewhere are announcing bans on the AI-powered chatbot ChatGPT. Teachers and school officials are wary of plagiarism, which is inevitable if students use ChatGPT for assignments. Many universities already use software that detects plagiarism.Many universities and institutions in India such as Dayananda Sagar University, RV University and also banned in schools of New york city, Los angeles, Washington D.C., France and etc.A group of Australian universities have said they would change exam formats to banish AI tools and regard them as cheating. The students are prohibited from using ChatGPT and are directed to submit original works for assessments.

Read Technical Log
Termux - Linux environment app for Android | Learn hacking with Android Device
2 min read
Jul 01, 2022 Security

Termux - Linux environment app for Android | Learn hacking with Android Device

Termux is an Android terminal application and Linux Environment. A Minimal base system is installed automatically, additional packages are available using the package manager. It provides a command line environment and allows you to install Linux apps on your android device. Termux is super-compact application that open up a lot of functionality for your android device. The command line is one of most powerful feature of Linux, and Termux builds on you device's Linux kernel to make you more efficient on the go. Termux is free shell environment for android.How to Install and setup Termuxyou can download termux via Play store Basic Command to use Termuxit is based on Linux environment, so it's commands literally to Linux commands,apt updatethis command is used to update Termux to latest version.apt upgradethis command upgrade all tools, and packages used in termuxclearthis command same as Linux terminal, used to clear screencd "path"To navigate to another directory or path, simply type this command, replace "path" with your directory nameexitExit command close the connection with termux and close the applsList all the directories and files available in the present path or directory, this command also same as Linux Terminalapt listShowing list of all packagesapt remove "package name"To remove any tools or package from termux, you have to use this command , just replace "package name" with the name of tools or packageapt install "package name"Use this command to install package or tools in termux. 

Read Technical Log