Skip to content

Instantly share code, notes, and snippets.

@tenman
Created February 7, 2013 03:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenman/4728293 to your computer and use it in GitHub Desktop.
Save tenman/4728293 to your computer and use it in GitHub Desktop.
WordPress Raindrops theme function raindrops_small_device_helper() has bug. Fixed code below.
/* WordPress theme Raindrops 1.004 line:3035
* function raindrops_small_device_helper has bug
* header image display improperly when uploading files 'Organize my uploads into month- and year-based folders' checked
* Please change below
* This bug will be fixed next versions Raindrops
*/
if ( ! function_exists( 'raindrops_small_device_helper' ) ) {
function raindrops_small_device_helper(){
global $is_IE, $raindrops_fluid_maximum_width;
$raindrops_header_image_uri = get_header_image();
?>
<script type="text/javascript">
(function(){
jQuery(function(){
var width = jQuery('div#header-image').width();
function raindrops_resizes(){
var image_exists = '<?php echo $raindrops_header_image_uri;?>';
var width = jQuery('div#header-image').width();
var window_width = jQuery(window).width();
if( image_exists !== '' ){
<?php
$url = get_theme_mod( 'header_image' );
if( $url == 'random-uploaded-image'){
$url = get_random_header_image();
}
$uploads = wp_upload_dir();
$file_name = basename( $url );
$child_path = '/'. $file_name;
$path = $uploads['path']. $child_path;
if( $url !== 'remove-header' ){
if( file_exists( $path ) ){
list($img_width, $img_height, $img_type, $img_attr) = getimagesize($path);
$ratio = $img_height / $img_width;
}else{
$raindrops_hd_images_path = get_template_directory().'/images/headers/'. basename( $url );
$ratio = 0.2084210;
}
?>
var ratio = <?php echo $ratio;?>;
var height = width * ratio;
jQuery('#header-image').removeAttr('style').css({'background-image':'url('+ image_exists + ')','height': height, 'background-size': 'cover'});
<?php }//remove header ?>
}
<?php
/**
* Check window size and mouse position
* Controll childlen menu show right or left side.
*
*
*
*/
?>
if ( jQuery('body > div').is('#doc3') ) {
jQuery("#access").mousemove(function(e){
var menu_item_position = e.pageX ;
if( window_width - 200 < menu_item_position){
jQuery('#access ul ul ul').addClass('left');
}else if( window_width / 2 > menu_item_position){
jQuery('#access ul ul ul').removeClass('left');
}
});
if( window_width > <?php echo $raindrops_fluid_maximum_width;?>){
//centering page when browser width > $raindrops_fluid_maximun_width
jQuery('#doc3').css({'margin':'auto'});
}
}
}
raindrops_resizes();
jQuery(window).resize( function () {raindrops_resizes()});
});
})(jQuery);
</script>
<?php
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment