Skip to content

Instantly share code, notes, and snippets.

@mor10
mor10 / advanced-featured-image.php
Last active August 29, 2015 14:01
Advanced responsive featured image function utilizing transients for caching.
@mor10
mor10 / my-responsive-thumbnail.php
Created May 28, 2014 01:46
Basic function to create responsive featured image in WordPress. Code to be added to functions.php.
<?php
/**
* Create function my_responsive_thumbnail() to output responsive featured image
* Function can be called from within the loop of any template file using my_responsive_thumbnail(get_the_ID());
*/
function my_responsive_thumbnail($post_id){
// Get the featured image ID
$attachment_id = get_post_thumbnail_id($post_id);
// Get the alt text or set the $alt_text variable to the post title if no alt text exists
@colllin
colllin / pathfinder.js
Last active March 15, 2016 07:42
Use jQuery to find the shortest selector for a given element in the DOM.
jQuery(function($) {
// returns an array of the potential selector components for the first element in the jQuery object. IDs, classes, and tagNames only.
var getSelectorComponents = function($el) {
var components = [];
var id = $el.attr('id');
if (typeof(id)!='undefined' && /[^\s]/.test(id)) {
components.push('#'+id);
}