' . "\n";
$out .= 'jQuery(function($) {' . "\n";
$out .= '$(' . '\'' . '.entry-content a' . '\'' . ').has(' . '\'' . 'img' . '\'' . ').attr(' . '\'' . HOOK . '\'' . ', ' . '\'' . GALLERY . '[' . $page . ']\'' . ');'. "\n";
$out .= '});' . "\n";
$out .= '' . "\n";
echo $out;
}
function Artwork_Gallery_footer_script()
{
$settings = array(
'animation_speed' => 'normal'
);
$PreOut = '' . "\n";
echo $PreOut;
foreach($settings as $key => $value)
{
echo $key.": '". $value . "', ";
}
echo $PostOut;
}
/*Add Date, Medium nad Dimensions to media uploader*/
function be_attachment_field_credit( $form_fields, $post ) {
$form_fields['artwork-date'] = array(
'label' => 'Date',
'input' => 'text',
'value' => get_post_meta( $post->ID, 'artwork_date', true ),
'helps' => 'The date of the project',
);
$form_fields['artwork-medium'] = array(
'label' => 'Medium',
'input' => 'text',
'value' => get_post_meta( $post->ID, 'artwork_medium', true ),
'helps' => 'Medium of the artwork',
);
$form_fields['artwork-dimensions'] = array(
'label' => 'Dimensions',
'input' => 'text',
'value' => get_post_meta( $post->ID, 'artwork_dimensions', true ),
'helps' => 'The dimensions, format: height vs. width',
);
// Set up options
$args = array(
'exclude' => '',
'sort_order' => 'ASC',
);
// $args = array( 'exclude' => '9,22,7', );
$pages = get_pages($args);
// Get currently selected value
$selected = get_post_meta( $post->ID, 'which_gallery', true );
// If no selected value, default to 'No'
if( !isset( $selected ) )
$selected = '0';
// Display each option
foreach ( $pages as $page ) {
$checked = '';
$css_id = 'which-gallery-option-' . $page->ID;
if ( $selected == $page->ID ) {
$checked = " checked='checked'";
}
$html = "
";
$html .= "";
$html .= "
";
// Display the default none option
if ($page === end($pages)){
$html .= " 'Which page you want this image on',
'input' => 'html',
'html' => join("\n", $out),
);
return $form_fields;
}
add_filter( 'attachment_fields_to_edit', 'be_attachment_field_credit', 10, 2 );
/*Save values of Date, Medium and Dimensions in media uploader*/
function be_attachment_field_credit_save( $post, $attachment ) {
if( isset( $attachment['artwork-date'] ) )
update_post_meta( $post['ID'], 'artwork_date', $attachment['artwork-date'] );
if( isset( $attachment['artwork-medium'] ) )
update_post_meta( $post['ID'], 'artwork_medium', $attachment['artwork-medium'] );
if( isset( $attachment['artwork-dimensions'] ) )
update_post_meta( $post['ID'], 'artwork_dimensions', $attachment['artwork-dimensions'] );
if( isset( $attachment['which-gallery'] ) )
update_post_meta( $post['ID'], 'which_gallery', $attachment['which-gallery'] );
return $post;
}
add_filter( 'attachment_fields_to_save', 'be_attachment_field_credit_save', 10, 2 );
/*Displays gallery in content window based on page selection*/
function Artwork_Create_Gallery() {
$content = get_the_content();
// do your transformation here
$content = '
'.$content.'
';
echo do_shortcode($content);
$postid = get_the_ID();
$args = array( 'post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'ASC', 'post_mime_type' => 'image' ,'post_status' => null, 'numberposts' => null, 'post_parent' => $post->ID );
$page = get_the_title();
$attachments = get_posts($args);
if ($attachments) {
echo '
';
foreach ( $attachments as $attachment ) {
$alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
$thumb_src = wp_get_attachment_thumb_url($attachment->ID);
$image_src = wp_get_attachment_url($attachment->ID, 'medium');
$image_title = $attachment->post_title;
$artwork_date = $attachment->artwork_date;
$artwork_medium = $attachment->artwork_medium;
$artwork_dimensions = $attachment->artwork_dimensions;
$which_gallery = $attachment->which_gallery;
$caption = $attachment->post_excerpt;
$description = $image->post_content;
if ($which_gallery == $postid) {
echo '
- ';
echo '';
echo '
';
echo '';
echo ' - ' . $image_title . '
';
echo '
';
}
}
echo '
';
}
}
?>