Ok for starters, I taught myself code over summer break and created the website https://www.prisimanimations.com/
It's basically a website for learning about and posting animations
One of the biggest obstacles I faced was figuring out a way for people to post their own animations with my page https://www.prisimanimations.com/animations.php
The process:
Originally I had it so people could just upload the file, but the issue with that was that uploads from mobile phone file sizes were extraordinarily huge. Since I'm not a million-dollar company, I had no way of compressing the files.
This meant that the person would have to have the video already uploaded on Youtube for it too work.
With that in mind that lead to two options :
Have the person upload an embed link - issue with this is it doesn't work from
mobile & it's kind of complicated (people are lazy)
Have the person upload the URL link - This is the one I went with, simple & easy
The next image was displaying the video itself (picture below). So to do so I had a generic YouTube logo with an anchor tag that when clicked would take you to the video. The issue is that it's not aesthetically pleasing, which I hated >:(
So today I was fiddling with the code of another page and notice the there's not much of a difference between an embed link and a normal url link
Ex:
Embed - https://www.youtube.com/embed/WGpzPll9U1A"
Normal Ur - https://www.youtube.com/watch?v=WGpzPll9U1A
The only difference is with the "/embed/" and the "watch?v=" in the url
My first Idea was using mysqli and uploading the url, searching, then replacing the
"watch?v=" automatically after it was uploaded. This one didn't work out well due to the way the upload system worked.
So then I started searching up ways to replace parts of a string variable and in the short terms figured out you could put the variable through a function, replace what you need to and then upload the result!
And that's what I did and it finally works! The url is automatically changed to an iframe embedded tag! So now the animations uploaded looks 10x better:D
Sorry for the rant, I'm just really excited I finally completed one of my biggest goals since the start of my website!
Nice work! It’s this kind of thing that makes programming addictive :)
Yeah, that's what I like about PHP, it's a lot less restrictive :D