Exemplo n.º 1
0
// Default width
$settings['height'] = 600;
// Default height
$settings['thumb_width'] = 150;
// Default thumbnail width
$settings['thumb_height'] = 150;
// Default thumbnail height
$settings['use_height'] = false;
// Use height value
$settings['post_id'] = get_the_ID();
// Post ID to get the attachments for
$settings['embed'] = '';
// Determine whether or not the post has an embedded video
$settings['use_embed'] = false;
// Determine whether to display the embed code, if one exists, in place of the post gallery/image.
$dimensions = woo_portfolio_image_dimensions($woo_options['woo_layout'], $woo_options['woo_layout_width']);
$settings['width'] = $dimensions['width'];
$settings['height'] = $dimensions['height'];
$settings['thumb_width'] = $dimensions['thumb_width'];
$settings['thumb_height'] = $dimensions['thumb_height'];
if ($settings['height'] > 0) {
    $settings['use_height'] = true;
}
if ($post_settings['embed'] != '') {
    $settings['use_embed'] = true;
}
$embed_args = 'width=' . ($settings['width'] - 6);
// Cater for the 3px border.
// Look for a video embed code.
$embed = woo_embed($embed_args);
if ($embed != '' && $settings['use_embed'] == true) {
Exemplo n.º 2
0
 function woo_portfolio_item_settings($id)
 {
     global $woo_options;
     // Sanity check.
     if (!is_numeric($id)) {
         return;
     }
     $website_layout = 'two-col-left';
     $website_width = '960px';
     if (isset($woo_options['woo_layout'])) {
         $website_layout = $woo_options['woo_layout'];
     }
     if (isset($woo_options['woo_layout_width'])) {
         $website_width = $woo_options['woo_layout_width'];
     }
     $dimensions = woo_portfolio_image_dimensions($website_layout, $website_width);
     $width = $dimensions['width'];
     $height = $dimensions['height'];
     $enable_gallery = false;
     if (isset($woo_options['woo_portfolio_gallery'])) {
         $enable_gallery = $woo_options['woo_portfolio_gallery'];
     }
     $settings = array('large' => '', 'caption' => '', 'rel' => '', 'gallery' => array(), 'css_classes' => 'group post portfolio-img', 'embed' => '', 'enable_gallery' => $enable_gallery, 'testimonial' => '', 'testimonial_author' => '', 'display_url' => '', 'width' => $width, 'height' => $height);
     $meta = get_post_custom($id);
     // Check if there is a gallery in post.
     // woo_get_post_images is offset by 1 by default. Setting to offset by 0 to show all images.
     $large = '';
     if (isset($meta['portfolio-image'][0])) {
         $large = $meta['portfolio-image'][0];
     }
     $caption = '';
     if ($settings['enable_gallery'] == 'true') {
         $gallery = woo_get_post_images('0');
         if ($gallery) {
             // Get first uploaded image in gallery
             $large = $gallery[0]['url'];
             $caption = $gallery[0]['caption'];
         }
     }
     // End IF Statement
     // If we only have one image, disable the gallery functionality.
     if (is_array($gallery) && count($gallery) <= 1) {
         $settings['enable_gallery'] = 'false';
     }
     // Check for a post thumbnail, if support for it is enabled.
     if ($woo_options['woo_post_image_support'] == 'true' && current_theme_supports('post-thumbnails')) {
         $image_id = get_post_thumbnail_id($id);
         if (intval($image_id) > 0) {
             $large_data = wp_get_attachment_image_src($image_id, 'large');
             if (is_array($large_data)) {
                 $large = $large_data[0];
             }
         }
     }
     // See if lightbox-url custom field has a value
     if (isset($meta['lightbox-url']) && $meta['lightbox-url'][0] != '') {
         $large = $meta['lightbox-url'][0];
     }
     // Set rel on anchor to show lightbox
     if (is_array($gallery) && count($gallery) <= 1) {
         $rel = 'rel="lightbox"';
     } else {
         $rel = 'rel="lightbox[' . $id . ']"';
     }
     // Create CSS classes string.
     $css = '';
     $galleries = array();
     $terms = get_the_terms($id, 'portfolio-gallery');
     if (is_array($terms) && count($terms) > 0) {
         foreach ($terms as $t) {
             $galleries[] = $t->slug;
         }
     }
     $css = join(' ', $galleries);
     // If on the single item screen, check for a video.
     if (is_singular()) {
         $settings['embed'] = woo_embed('width=540');
     }
     // Add testimonial information.
     if (isset($meta['testimonial']) && $meta['testimonial'][0] != '') {
         $settings['testimonial'] = $meta['testimonial'][0];
     }
     if (isset($meta['testimonial_author']) && $meta['testimonial_author'][0] != '') {
         $settings['testimonial_author'] = $meta['testimonial_author'][0];
     }
     // Look for a custom display URL of the portfolio item (used if it's a website, for example)
     if (isset($meta['url']) && $meta['url'][0] != '') {
         $settings['display_url'] = $meta['url'][0];
     }
     // Assign the values we have to our array.
     $settings['large'] = $large;
     $settings['caption'] = $caption;
     $settings['rel'] = $rel;
     $settings['gallery'] = $gallery;
     $settings['css_classes'] .= ' ' . $css;
     // Disable "enable_gallery" option is gallery is empty.
     if (!is_array($settings['gallery']) || $settings['gallery'] == '' || count($settings['gallery']) <= 0) {
         $settings['enable_gallery'] = 'false';
     }
     // Allow child themes/plugins to filter these settings.
     $settings = apply_filters('woo_portfolio_item_settings', $settings, $id);
     return $settings;
 }
Exemplo n.º 3
0
// Number of maximum attachments to get
$settings['photo_size'] = 'large';
// The WP "size" to use for the large image
$settings['width'] = 520;
// Default width
$settings['height'] = 600;
// Default height
$settings['use_height'] = false;
// Use height value
$settings['post_id'] = get_the_ID();
// Post ID to get the attachments for
$settings['embed'] = '';
// Determine whether or not the post has an embedded video
$settings['use_embed'] = false;
// Determine whether to display the embed code, if one exists, in place of the post gallery/image.
$dimensions = woo_portfolio_image_dimensions(woo_get_layout(), $woo_options['woo_layout_width']);
$settings['width'] = $dimensions['width'];
$settings['height'] = $dimensions['height'];
$settings['thumb_width'] = $dimensions['thumb_width'];
$settings['thumb_height'] = $dimensions['thumb_height'];
if ($settings['height'] > 0) {
    $settings['use_height'] = true;
}
if ($post_settings['embed'] != '') {
    $settings['use_embed'] = true;
}
$embed_args = 'width=' . ($settings['width'] - 6);
// Cater for the 3px border.
// Look for a video embed code.
$embed = woo_embed($embed_args);
if ($embed != '' && $settings['use_embed'] == true) {