Skip to content

Instantly share code, notes, and snippets.

@scofennell
scofennell / sjf_deh_get_photo_creds.php
Last active August 29, 2015 14:01
WordPress function to return the name of the photographer of a photo.
<?php
/**
* Returns the name of the photographer for the current post, along with a Font Awesome icon.
*
* @return string The name of the photographer for the current post, along with a Font Awesome icon.
*/
function sjf_deh_get_photo_creds() {
// get the current post
$post = get_post();
@scofennell
scofennell / vardump_attachment.php
Created May 22, 2014 14:53
var_dump of WordPress attachment
<?php
object(WP_Post)#29 (24) {
["ID"]=> int(161)
["post_author"]=> string(1) "1"
["post_date"]=> string(19) "2014-05-22 14:48:05"
["post_date_gmt"]=> string(19) "2014-05-22 14:48:05"
["post_content"]=> string(54) "Image description, with HTML"
["post_title"]=> string(11) "Image Title"
["post_excerpt"]=> string(13) "Image Caption"
@scofennell
scofennell / sjf_deh_gallery.php
Last active August 29, 2015 14:01
WordPress Masonry Gallery Shortcode
@scofennell
scofennell / sjf_deh_is_portrait.php
Created May 23, 2014 01:00
WordPres function to detect if an image is a portrait, by aspect ratio
<?php
/**
* Given an attachment_id and a definition of portraiture, detect if a photo is a portrait
*
* @param int $attachment_id the attachment_id for the image
* @param mixed $max_ratio the aspect ratio that defines portraiture
* @return boolean returns true if image is a portrait, otherwise returns false
*/
function sjf_deh_is_portrait( $attachment_id, $max_ratio='.67' ){
@scofennell
scofennell / sjf_deh_get_nav_links.php
Last active August 29, 2015 14:01
WordPress function to get links to adjacent gallery images, bookend images, and parent page
@scofennell
scofennell / sjf_deh_get_adjacent_image_link.php
Last active August 29, 2015 14:01
WordPress function to get adjacent gallery images
@scofennell
scofennell / sjf_deh_define_image_sizes.php
Last active August 29, 2015 14:01
WordPress snippet for dealing with image sizes
<?php
/**
* Standard practice among WordPress themes is to declare the width of the main content column as a global.
*
* @var integer
*/
$content_width = 800;
/**
@scofennell
scofennell / sjf_deh_save_custom_meta.php
Last active June 20, 2017 16:06
WordPress function to save custom meta box for attachment posts
<?php
/**
* Save the Data
*
*/
function sjf_deh_save_custom_meta( $post_id ) {
// Check if the nonce exists.
if( ! isset( $_POST[ 'sjf_deh_custom_meta_box_nonce' ] ) ) { return $post_id; }
@scofennell
scofennell / full_page_background.html
Last active August 29, 2015 14:01
Markup for Full Page Background
<!DOCTYPE html>
<html lang="en-US">
<head>
...
<!-- styles added by sjf_deh_the_bg_image_styles() to position the page bg image -->
<style>
#page {
background: url(http://scottfennell.com/wp-content/uploads/2014/04/IMG_1405-2000x1333.jpg) no-repeat center center fixed;
@scofennell
scofennell / full_page_bg.css
Created May 25, 2014 23:20
CSS for full-page background-image
#page {
width: 100%;
height: 100%;
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
}