Skip to content

Instantly share code, notes, and snippets.

View uptheirons78's full-sized avatar
😉
Freelancing or Job Searching ? Help Me!

Mauro Bono uptheirons78

😉
Freelancing or Job Searching ? Help Me!
View GitHub Profile
@uptheirons78
uptheirons78 / image-with-srcset.php
Created March 27, 2023 18:24
WordPress Image Tag with srcset
function storebase_get_image_output($image_id, $size = 'large', $sizes = '(max-width: 768px) 100vw, (max-width: 1024px) 50vw, 33vw') {
$alt = get_post_meta( $image_id, '_wp_attachment_image_alt', true );
$metadata = wp_get_attachment_metadata( $image_id );
$src = wp_get_attachment_image_src( $image_id, $size )[0];
$srcset = wp_get_attachment_image_srcset( $image_id, $size );
$width = $metadata['width'];
$height = $metadata['height'];
$output = '<img src="' . $src . '"';
@uptheirons78
uptheirons78 / event-card-pattern.php
Created March 10, 2023 09:50
Register a WordPress Pattern
<?php
/**
* Title: Event Card
* Slug: text-domain/event-card
* Categories: cards
*/
?>
<!-- wp:group {"className":"specifica-opera","layout":{"type":"default"}} -->
<div class="wp-block-group specifica-opera"><!-- wp:heading {"textColor":"hc_azzurro"} -->
<h2 class="has-hc-azzurro-color has-text-color">Missa Brevis in La Maggiore BWV 234</h2>
@uptheirons78
uptheirons78 / ai1wpm-exclude-node-modules.php
Created January 5, 2023 11:17
All In One WP Migration: exclude node_modules from export files
<?php
/**
* All In One WP Migration: exclude node_modules folder from export files
*
* Change 'your-theme-name' with the real name of your theme folder
* save this file inside your 'inc' folder and require it inside 'functions.php'
*
* @package Your_Theme_Name
*/
function mb_ai1wm_exclude_node_modules($exclude_filters) {
@uptheirons78
uptheirons78 / index.js
Created January 31, 2020 14:51
Hex to Rgba Colors Converter Function
const hexToRGBA = (hex, opacity) => {
// remove # from hex color string
const value = hex.replace("#", '');
// get red, green and blue pairings and convert them to their equivalent hexadecimal number
const red = parseInt(value.substring(0,2), 16);
const green = parseInt(value.substring(2,4), 16);
const blue = parseInt(value.substring(4,6), 16);
// return rgba value adding opacity
return `rgba(${red}, ${green}, ${blue}, ${opacity})`;
}
@uptheirons78
uptheirons78 / .block
Last active February 20, 2018 14:05
GDP_BarChart
license: mit
@uptheirons78
uptheirons78 / .block
Created February 19, 2018 13:26
Another Scatterplot
license: mit
@uptheirons78
uptheirons78 / .block
Last active February 19, 2018 13:23
First ScatterPlot
license: mit