This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Function for responsive featured images. | |
* Create a <picture> element and populate it with appropriate image sizes for different screen widths. | |
* Works in place of the_post_thumbnail(); | |
*/ | |
function simone_the_responsive_thumbnail($post_id) { | |
// Check to see if there is a transient available. If there is, use it. | |
if ( false === ( $thumb_data = get_transient( 'featured_image_' . $post_id ) ) ) { | |
simone_set_image_transient($post_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |