Skip to content

Instantly share code, notes, and snippets.

View tilap's full-sized avatar

Tilap tilap

View GitHub Profile
@tilap
tilap / urlToFile.js
Created July 5, 2014 11:06
nodejs: copy remote web file on local
/*
* copy remote web file on local
*
* usage:
* require('urlToFile')('http://domain.tld/image.jpg', '/local/path/image.jpg', function() {console.log('success !');}, function(message) {console.log(message);});
*/
var http = require('http');
var fs = require('fs');
@tilap
tilap / functions.php
Last active July 23, 2023 09:29
Wordpress: How to automatically attache youtube/vimeo thumbnail as a post feature image from a post meta key
function insertThumbnail($data, $postArr) {
if(!isset($postArr['ID'])) {
return $data;
}
$postId = $postArr['ID'];
$metaKey = 'you-post-meta-video-key'; // the custom meta key
// If video and video format
if(isset($postArr[$metaKey]) && ''!==$postArr[$metaKey] ) {