Skip to content

Instantly share code, notes, and snippets.

@halgatewood
Last active September 26, 2017 21:27
Show Gist options
  • Select an option

  • Save halgatewood/11da92fc493757e64a6b55a6eabde7f5 to your computer and use it in GitHub Desktop.

Select an option

Save halgatewood/11da92fc493757e64a6b55a6eabde7f5 to your computer and use it in GitHub Desktop.
A simple custom template that has a background video. It is based off the Wide default template.
<?php $weather_name = awesome_weather_preset_condition_names_openweathermaps( $weather->data['current']['condition_code']); ?>
<style>
.awesome-weather-main-content {
position: relative;
z-index: 10;
}
.awesome-weather-video-background {
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
overflow:hidden;
z-index: 0;
}
.awesome-weather-video-background video {
position: absolute;
min-width: 100%;
min-height: 100%;
max-width: none;
max-height: none;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
</style>
<div id="awesome-weather-<?php echo $weather->city_slug; ?>" class="awe_wide awe_video <?php echo $background_classes ?>" <?php echo $inline_style; ?>>
<div class="awesome-weather-video-background">
<video loop="" muted="" autoplay="" poster="<?php echo $weather->background_image; ?>">
<source src="http://urltovideo/<?php echo $weather_name; ?>.mp4" type="video/mp4">
<source src="http://urltovideo/<?php echo $weather_name; ?>.webm" type="video/webm">
</video>
</div>
<div class="awesome-weather-main-content">
<?php awe_change_weather_form( $weather ); ?>
<div class="awesome-weather-header awecf"><span><?php echo $header_title; ?><?php awe_change_weather_trigger( $weather ); ?></span></div>
<?php if( isset($weather->data['current'])) { ?>
<div class="awecf">
<div class="awesome-weather-current-temp">
<strong>
<?php echo $weather->data['current']['temp']; ?><sup>&deg;</sup>
<?php if($weather->show_icons) { ?><i class="<?php echo $weather->data['current']['icon']; ?>"></i><?php } ?>
</strong>
</div><!-- /.awesome-weather-current-temp -->
<?php if($weather->show_stats) { ?>
<div class="awesome-weather-todays-stats">
<div class="awe_desc"><?php echo $weather->data['current']['description']; ?></div>
<div class="awe_humidty"><?php echo $weather->data['current']['humidity']; ?>% <?php _e('humidity', 'awesome-weather-pro'); ?></div>
<div class="awe_wind"><?php _e('wind:', 'awesome-weather-pro'); ?> <?php echo $weather->data['current']['wind_speed']; ?><?php echo $weather->data['current']['wind_speed_text']; ?> <?php echo $weather->data['current']['wind_direction']; ?></div>
<div class="awe_highlow"><?php _e('H', 'awesome-weather-pro'); ?> <?php echo $weather->data['current']['high']; ?> &bull; <?php _e('L', 'awesome-weather-pro'); ?> <?php echo $weather->data['current']['low']; ?></div>
</div><!-- /.awesome-weather-todays-stats -->
<?php } ?>
</div>
<?php } ?>
<?php if($weather->forecast_days != "hide") { ?>
<div class="awesome-weather-forecast awe_days_<?php echo count($weather_forecast); ?> awecf">
<?php foreach( $weather_forecast as $forecast ) { ?>
<div class="awesome-weather-forecast-day">
<?php if($weather->show_icons) { ?><i class="<?php echo $forecast->icon; ?>"></i><?php } ?>
<div class="awesome-weather-forecast-day-temp"><?php echo $forecast->temp; ?><sup>&deg;</sup></div>
<div class="awesome-weather-forecast-day-abbr"><?php echo $forecast->day_of_week; ?></div>
</div>
<?php } ?>
</div><!-- /.awesome-weather-forecast -->
<?php } ?>
<?php awe_extended_link( $weather ); ?>
<?php awe_attribution( $weather ); ?>
</div>
</div><!-- /.awesome-weather-wrap: video -->
@thedotcom
Copy link

Also what if I want to use yahoo weather api? They seem to be more accurate...

@halgatewood
Copy link
Author

halgatewood commented Sep 26, 2017

You would need to change the function at the very top to: awesome_weather_preset_condition_names_yahoo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment