Skip to content

Instantly share code, notes, and snippets.

Avatar

Diego Betto diego-betto

View GitHub Profile
@diego-betto
diego-betto / video-ios.html
Created Sep 17, 2020
Video with autoplay, loop and iOS support
View video-ios.html
<video autoplay loop muted playsinline class="video-background ">
<source src="to/the/video.mp4" type="video/mp4">
</video>
@diego-betto
diego-betto / image-start-end-alpha.js
Last active Dec 13, 2017
Detects the beginning and end of an image along its center
View image-start-end-alpha.js
function getRealImageYStartEnd($imageId){
var img = document.getElementById($imageId);
var canvas = document.createElement('canvas');
canvas.width = img.width;
canvas.height = img.height;
canvas.getContext('2d').drawImage(img, 0, 0, img.width, img.height);
var context = canvas.getContext('2d');
var middle = Math.floor(img.width/2);
var startImage = 0;
@diego-betto
diego-betto / jquery-footer.functions.php
Created Oct 20, 2017
Wordpres: move jQuery to the footer
View jquery-footer.functions.php
@diego-betto
diego-betto / disable-default-embeds.functions.php
Last active Oct 20, 2017
Disable default Wordpress embeds in frontend
View disable-default-embeds.functions.php
<?php
// in functions.php
if (!is_admin()){
remove_action( 'rest_api_init', 'wp_oembed_register_route' );
add_filter( 'embed_oembed_discover', '__return_false' );
remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
remove_action( 'wp_head', 'wp_oembed_add_host_js' );
@diego-betto
diego-betto / iubenda-check-consent.js
Created Oct 11, 2017
Iubenda, check consent given in javascript
View iubenda-check-consent.js
@diego-betto
diego-betto / custom-navbar-breakpoint.bootstrap.css
Created Sep 26, 2017
Change Bootstrap 3 navbar collapse point
View custom-navbar-breakpoint.bootstrap.css
@media (max-width: 1200px) {
.navbar-header {
float: none;
}
.navbar-left,.navbar-right {
float: none !important;
}
.navbar-toggle {
display: block;
}
@diego-betto
diego-betto / no-scroll-input-focus.css
Last active Sep 26, 2017
Tablet & Mobile: Avoid scroll on input focus
View no-scroll-input-focus.css
html,body{
-webkit-overflow-scrolling : touch !important;
overflow: auto !important;
height: 100% !important;
}
@diego-betto
diego-betto / DOM-Ready.js
Created Sep 7, 2017 — forked from franzese/DOM-Ready.js
Vanilla JavaScript Document Ready
View DOM-Ready.js
Document.prototype.ready = function(callback) {
if(callback && typeof callback === 'function') {
document.addEventListener("DOMContentLoaded", function() {
if(document.readyState === "interactive" || document.readyState === "complete") {
return callback();
}
});
}
};
@diego-betto
diego-betto / inline-svg.functions.php
Last active Sep 26, 2017
Wordpress Theme: Inline Embed SVG files
View inline-svg.functions.php
<?php
// in functions.php
function inlineSvg($file)
{
$theFile = get_template_directory().'/'.$file.'.svg';
echo (is_file($theFile) ? file_get_contents(get_template_directory().'/'.$file.'.svg') : '');
}
@diego-betto
diego-betto / bootstrap3-ios-modal-iframe-fix.css
Created Apr 10, 2017
Bootstrap 3 iOS modal iframe scrolling fix
View bootstrap3-ios-modal-iframe-fix.css
.iframe-wrapper {
overflow: auto;
-webkit-overflow-scrolling: touch;
}
You can’t perform that action at this time.