Last active
August 29, 2015 14:14
-
-
Save ericakfranz/1d65045a169a0ef4d69d to your computer and use it in GitHub Desktop.
Output specific image dimensions to Soliloquy slides, based on slider ID
This file contains hidden or 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
/** | |
* Plugin Name: Soliloquy - Output Specific Images Sizes Based on Slider ID | |
* Plugin URI: http://soliloquywp.com | |
* Version: 1.0 | |
* Author: Erica Franz | |
* Author URI: http://fatpony.me/ | |
* Description: Output specific image dimensions to Soliloquy slides, based on slider ID | |
*/ | |
/** | |
* Exclude the Soliloquy CPT from search results | |
* | |
* @param string $attributes Image HTML attributes | |
* @param int|string $id The ID for the slide. | |
* @param array $item Array of data for the slide. | |
* @param array $data Array of data for the slider. | |
* @param int $i The number of the slide in the slider. | |
* @return string Image HTML attributes | |
*/ | |
function soliloquy_output_custom_slider_image_sizes( $attributes, $id, $item, $data, $i ) { | |
// IDs of sliders to output image dimensions in | |
$slidersToAddDimensions = array( | |
18, | |
42 | |
); | |
$ID = $data['id']; | |
// Check if we need to output image dimensions in these sliders | |
if ( !in_array( $ID, $slidersToAddDimensions ) ) { | |
return $dimensions; | |
} | |
// Add dimensions to Slider ID 18, but not ID 42 | |
if ( $ID = 18 && $ID != 42 ) { | |
$dimensions .= ' height="300" width="300"'; | |
} | |
// Add dimensions to Slider ID 42, but not ID 18 | |
if ( $ID = 42 && $ID != 18 ) { | |
$dimensions .= ' height="500" width="500"'; | |
} | |
return $dimensions; | |
} | |
add_filter( 'soliloquy_output_image_attr', 'soliloquy_output_custom_slider_image_sizes', 10, 5 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment