Skip to content

Instantly share code, notes, and snippets.

View elipettingale's full-sized avatar

Elliot Pettingale elipettingale

View GitHub Profile
@elipettingale
elipettingale / ImageUpload.js
Created January 6, 2022 07:06
Image file upload preview
export default class ImageUpload {
constructor(root) {
this.root = root;
this.input = root.querySelector('input');
this.preview = root.querySelector('img');
this.input.addEventListener('change', (event) => this.onChange(event));
}
onChange(event) {
@elipettingale
elipettingale / .bash_aliases
Last active July 21, 2022 08:13
PHP Version Manager - quickly switch terminal to a specific version of php
function pvm() {
if [ $1 = "use" ]
then
if [ -z "$2" ]
then
if [ -f ".pvmrc" ]
then
VERSION=$(cat .pvmrc)
eval "pvm use $VERSION"
else
@elipettingale
elipettingale / admin.css
Last active August 3, 2021 07:13
Wordpress | Increases the Gutenberg editor width to something that isn't ridiculous
.wp-block {
max-width: 1200px;
}
@elipettingale
elipettingale / functions.php
Last active April 1, 2020 07:52
Wordpress | Upload post featured image from url
<?php
$upload = wp_upload_bits(basename($image_url), null, file_get_contents($image_url));
$image_file = $upload['file'];
$image_type = wp_check_filetype($image_file, null);
$attachment_id = wp_insert_attachment([
'post_mime_type' => $image_type['type'],
'post_title' => sanitize_file_name($image_file),