Skip to content

Instantly share code, notes, and snippets.


Max John kressly

  • Use Faith Group Ltd
  • Ghana
View GitHub Profile
View remote-image-cache.php
function cache_image($image_url){
//replace with your cache directory
$image_path = 'path/to/cache/dir/';
//get the name of the file
$exploded_image_url = explode("/",$image_url);
$image_filename = end($exploded_image_url);
$exploded_image_filename = explode(".",$image_filename);
$extension = end($exploded_image_filename);
//make sure its an image
kressly / youtube_id_regex.php
Created Jul 9, 2018 — forked from ghalusa/youtube_id_regex.php
Extract the YouTube Video ID from a URL in PHP
View youtube_id_regex.php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
kressly / Video generator
Created Apr 1, 2018 — forked from jimmylatreille/Video generator
Youtube, Vimeo and Dailymotion script
View Video generator
if(preg_match('/vimeo/', $data['url'])){
$url = '//'.end(explode('/', $data['url']));
echo "<iframe src='$url' width='560' height='315' frameborder='0' webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>";
echo "<img src='".unserialize(file_get_contents("".end(explode('/', $data['url'])).".php"))[0]['thumbnail_medium']."' />";
View handle_file_upload.php
$fileName = $_FILES['afile']['name'];
$fileType = $_FILES['afile']['type'];
$fileContent = file_get_contents($_FILES['afile']['tmp_name']);
$dataUrl = 'data:' . $fileType . ';base64,' . base64_encode($fileContent);
$json = json_encode(array(
'name' => $fileName,
'type' => $fileType,
'dataUrl' => $dataUrl,