Skip to content

Instantly share code, notes, and snippets.

View sagarjadhav's full-sized avatar

Sagar Jadhav sagarjadhav

  • rtCamp Inc
  • Pune
View GitHub Profile
@sagarjadhav
sagarjadhav / image-cropping.php
Last active April 21, 2017 12:15
Image cropping fix
<?php
if ( has_post_thumbnail( $post_id ) ) {
// Get Featured Image
$class = 'img-thumb';
$post_thumbnail_id = get_post_thumbnail_id( $post_id );
$image_exists = wp_get_attachment_image_src( $post_thumbnail_id, 'thumbnail-size' );
if ( !$image_exists[ 3 ] ) {
$class = 'img-not-thumb';
}
@sagarjadhav
sagarjadhav / ipad-hover-dropdown.js
Created August 23, 2017 15:52
Drop-Down Navigation: Touch-Friendly
;(function( $, window, document, undefined )
{
$.fn.doubleTapToGo = function( params )
{
if( !( 'ontouchstart' in window ) &&
!navigator.msMaxTouchPoints &&
!navigator.userAgent.toLowerCase().match( /windows phone os 7/i ) ) return false;
this.each( function()
{
@sagarjadhav
sagarjadhav / gf_tabindex.php
Created September 15, 2017 03:54
Fix Gravity Form Tabindex Conflicts
<?php
/**
* Fix Gravity Form Tabindex Conflicts
*/
if ( !function_exists( 'gform_tabindexer' ) ) {
function gform_tabindexer( $tab_index, $form = false ) {
$starting_index = 1000;
if ( $form ) {
$( '<ul id="bp-members-order-by" class="bs-dropdown bs-dropdown-order" />' ).appendTo( '#bp-members-order-select' );
$( '#members-order-by option' ).each(function() {
var el = $(this);
$('<li />', {}).appendTo( '#bp-members-order-by' );
$('<a />', {
'href' : el.attr( 'value' ),
'text' : el.text()
@sagarjadhav
sagarjadhav / slick-customPaging-img.js
Created October 4, 2021 15:57
Slick slider custom Paging with Image and accessibility
$( document ).on( 'ready', () => {
$( '.slider-nav' ).slick( {
responsive: [
{
breakpoint: 767,
settings: {
dots: true,
customPaging: function( slick, index ) {
var targetImage = slick.$slides.eq( index ).find( 'img' ).attr( 'src' );
return '<button><img src=" ' + targetImage + ' " alt="image" /></button>';
@sagarjadhav
sagarjadhav / wp-image-alt-attr.php
Created October 12, 2021 12:07
Filter attachment image attributes to inject alt attribute to Image
<?php
if ( ! function_exists( 'rtcamp_add_img_alt_attribute' ) ) {
/**
* Filter attachment image attributes to inject alt attribute.
*
* @param string[] $attrs Array of attribute values for the image markup, keyed by attribute name.
* @param WP_Post|null $attachment Image attachment post.
* @return string[] Filtered attributes.
*/