Last active
September 28, 2016 23:37
-
-
Save jo-flynn/cf8968ed90e560094eb0e3684beef493 to your computer and use it in GitHub Desktop.
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 | |
$page_meta = new_cmb2_box([ | |
'id' => 'page_meta', | |
'title' => 'Page Options', | |
'object_types' => ['page'], | |
'context' => 'normal', | |
'priority' => 'high', | |
'show_names' => true | |
]); | |
$page_meta->add_field([ | |
'id' => 'via_mobile_featured', | |
'name' => 'Mobile Featured Image', | |
'desc' => "Add a header image for mobile devices only. Won't show without a featured image assigned.", | |
'type' => 'file', | |
'options' => [ | |
'url' => false | |
], | |
]); |
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 | |
$mobile_thumbnail = get_post_meta($post->ID, 'via_mobile_featured', true); | |
$thumbnail = get_post_thumbnail_url('full'); | |
?> | |
<style type="text/css"> | |
<?php | |
if (!empty($mobile_thumbnail)) { | |
?> | |
.page-header { | |
background-image: url('<?php echo $mobile_thumbnail; ?>'); | |
} | |
@media (min-width: 768px) { | |
.page-header { | |
background-image: url('<?php echo $thumbnail; ?>'); | |
} | |
} | |
<?php | |
} else { | |
?> | |
.page-header { | |
background-image: url('<?php echo $thumbnail; ?>'); | |
} | |
<?php | |
} | |
?> | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment