Exemple #1
0
 /**
  * Get the url for a media attachment for an AJAX request
  */
 public function ajax_media_url()
 {
     if (isset($_POST['attachment_id']) && is_numeric($_POST['attachment_id'])) {
         // determine size to retrieve
         $size = isset($_POST['attachment_size']) ? $_POST['attachment_size'] : 'full';
         // try to get the attachment info
         $src = nxt_get_attachment_image_src($_POST['attachment_id'], $size);
         // check it out
         if (is_array($src)) {
             ICE_Ajax::response(true, $src[0], $src[1], $src[2]);
         } else {
             ICE_Ajax::response(false, __('Failed to lookup attachment URL', infinity_text_domain));
         }
     } else {
         ICE_Ajax::response(0, __('No attachment ID received', infinity_text_domain));
     }
 }
Exemple #2
0
/**
 * Retrieve HTML form for modifying the image attachment.
 *
 * @since 2.5.0
 *
 * @param int $attachment_id Attachment ID for modification.
 * @param string|array $args Optional. Override defaults.
 * @return string HTML form for attachment.
 */
function get_media_item($attachment_id, $args = null)
{
    global $redir_tab;
    if (($attachment_id = intval($attachment_id)) && ($thumb_url = nxt_get_attachment_image_src($attachment_id, 'thumbnail', true))) {
        $thumb_url = $thumb_url[0];
    } else {
        $thumb_url = false;
    }
    $post = get_post($attachment_id);
    $current_post_id = !empty($_GET['post_id']) ? (int) $_GET['post_id'] : 0;
    $default_args = array('errors' => null, 'send' => $current_post_id ? post_type_supports(get_post_type($current_post_id), 'editor') : true, 'delete' => true, 'toggle' => true, 'show_title' => true);
    $args = nxt_parse_args($args, $default_args);
    $args = apply_filters('get_media_item_args', $args);
    extract($args, EXTR_SKIP);
    $toggle_on = __('Show');
    $toggle_off = __('Hide');
    $filename = esc_html(basename($post->guid));
    $title = esc_attr($post->post_title);
    if ($_tags = get_the_tags($attachment_id)) {
        foreach ($_tags as $tag) {
            $tags[] = $tag->name;
        }
        $tags = esc_attr(join(', ', $tags));
    }
    $post_mime_types = get_post_mime_types();
    $keys = array_keys(nxt_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
    $type = array_shift($keys);
    $type_html = "<input type='hidden' id='type-of-{$attachment_id}' value='" . esc_attr($type) . "' />";
    $form_fields = get_attachment_fields_to_edit($post, $errors);
    if ($toggle) {
        $class = empty($errors) ? 'startclosed' : 'startopen';
        $toggle_links = "\n\t<a class='toggle describe-toggle-on' href='#'>{$toggle_on}</a>\n\t<a class='toggle describe-toggle-off' href='#'>{$toggle_off}</a>";
    } else {
        $class = '';
        $toggle_links = '';
    }
    $display_title = !empty($title) ? $title : $filename;
    // $title shouldn't ever be empty, but just in case
    $display_title = $show_title ? "<div class='filename new'><span class='title'>" . nxt_html_excerpt($display_title, 60) . "</span></div>" : '';
    $gallery = isset($_REQUEST['tab']) && 'gallery' == $_REQUEST['tab'] || isset($redir_tab) && 'gallery' == $redir_tab;
    $order = '';
    foreach ($form_fields as $key => $val) {
        if ('menu_order' == $key) {
            if ($gallery) {
                $order = "<div class='menu_order'> <input class='menu_order_input' type='text' id='attachments[{$attachment_id}][menu_order]' name='attachments[{$attachment_id}][menu_order]' value='" . esc_attr($val['value']) . "' /></div>";
            } else {
                $order = "<input type='hidden' name='attachments[{$attachment_id}][menu_order]' value='" . esc_attr($val['value']) . "' />";
            }
            unset($form_fields['menu_order']);
            break;
        }
    }
    $media_dims = '';
    $meta = nxt_get_attachment_metadata($post->ID);
    if (is_array($meta) && array_key_exists('width', $meta) && array_key_exists('height', $meta)) {
        $media_dims .= "<span id='media-dims-{$post->ID}'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> ";
    }
    $media_dims = apply_filters('media_meta', $media_dims, $post);
    $image_edit_button = '';
    if (gd_edit_image_support($post->post_mime_type)) {
        $nonce = nxt_create_nonce("image_editor-{$post->ID}");
        $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <img src='" . esc_url(admin_url('images/nxtspin_light.gif')) . "' class='imgedit-wait-spin' alt='' />";
    }
    $attachment_url = get_permalink($attachment_id);
    $item = "\n\t{$type_html}\n\t{$toggle_links}\n\t{$order}\n\t{$display_title}\n\t<table class='slidetoggle describe {$class}'>\n\t\t<thead class='media-item-info' id='media-head-{$post->ID}'>\n\t\t<tr valign='top'>\n\t\t\t<td class='A1B1' id='thumbnail-head-{$post->ID}'>\n\t\t\t<p><a href='{$attachment_url}' target='_blank'><img class='thumbnail' src='{$thumb_url}' alt='' /></a></p>\n\t\t\t<p>{$image_edit_button}</p>\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t<p><strong>" . __('File name:') . "</strong> {$filename}</p>\n\t\t\t<p><strong>" . __('File type:') . "</strong> {$post->post_mime_type}</p>\n\t\t\t<p><strong>" . __('Upload date:') . "</strong> " . mysql2date(get_option('date_format'), $post->post_date) . '</p>';
    if (!empty($media_dims)) {
        $item .= "<p><strong>" . __('Dimensions:') . "</strong> {$media_dims}</p>\n";
    }
    $item .= "</td></tr>\n";
    $item .= "\n\t\t</thead>\n\t\t<tbody>\n\t\t<tr><td colspan='2' class='imgedit-response' id='imgedit-response-{$post->ID}'></td></tr>\n\t\t<tr><td style='display:none' colspan='2' class='image-editor' id='image-editor-{$post->ID}'></td></tr>\n";
    $defaults = array('input' => 'text', 'required' => false, 'value' => '', 'extra_rows' => array());
    if ($send) {
        $send = get_submit_button(__('Insert into Post'), 'button', "send[{$attachment_id}]", false);
    }
    if ($delete && current_user_can('delete_post', $attachment_id)) {
        if (!EMPTY_TRASH_DAYS) {
            $delete = "<a href='" . nxt_nonce_url("post.php?action=delete&amp;post={$attachment_id}", 'delete-attachment_' . $attachment_id) . "' id='del[{$attachment_id}]' class='delete'>" . __('Delete Permanently') . '</a>';
        } elseif (!MEDIA_TRASH) {
            $delete = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_{$attachment_id}').style.display='block';return false;\">" . __('Delete') . "</a>\n\t\t\t <div id='del_attachment_{$attachment_id}' class='del-attachment' style='display:none;'>" . sprintf(__('You are about to delete <strong>%s</strong>.'), $filename) . "\n\t\t\t <a href='" . nxt_nonce_url("post.php?action=delete&amp;post={$attachment_id}", 'delete-attachment_' . $attachment_id) . "' id='del[{$attachment_id}]' class='button'>" . __('Continue') . "</a>\n\t\t\t <a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __('Cancel') . "</a>\n\t\t\t </div>";
        } else {
            $delete = "<a href='" . nxt_nonce_url("post.php?action=trash&amp;post={$attachment_id}", 'trash-attachment_' . $attachment_id) . "' id='del[{$attachment_id}]' class='delete'>" . __('Move to Trash') . "</a>\n\t\t\t<a href='" . nxt_nonce_url("post.php?action=untrash&amp;post={$attachment_id}", 'untrash-attachment_' . $attachment_id) . "' id='undo[{$attachment_id}]' class='undo hidden'>" . __('Undo') . "</a>";
        }
    } else {
        $delete = '';
    }
    $thumbnail = '';
    $calling_post_id = 0;
    if (isset($_GET['post_id'])) {
        $calling_post_id = absint($_GET['post_id']);
    } elseif (isset($_POST) && count($_POST)) {
        // Like for async-upload where $_GET['post_id'] isn't set
        $calling_post_id = $post->post_parent;
    }
    if ('image' == $type && $calling_post_id && current_theme_supports('post-thumbnails', get_post_type($calling_post_id)) && post_type_supports(get_post_type($calling_post_id), 'thumbnail') && get_post_thumbnail_id($calling_post_id) != $attachment_id) {
        $ajax_nonce = nxt_create_nonce("set_post_thumbnail-{$calling_post_id}");
        $thumbnail = "<a class='nxt-post-thumbnail' id='nxt-post-thumbnail-" . $attachment_id . "' href='#' onclick='nxtSetAsThumbnail(\"{$attachment_id}\", \"{$ajax_nonce}\");return false;'>" . esc_html__("Use as featured image") . "</a>";
    }
    if (($send || $thumbnail || $delete) && !isset($form_fields['buttons'])) {
        $form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>{$send} {$thumbnail} {$delete}</td></tr>\n");
    }
    $hidden_fields = array();
    foreach ($form_fields as $id => $field) {
        if ($id[0] == '_') {
            continue;
        }
        if (!empty($field['tr'])) {
            $item .= $field['tr'];
            continue;
        }
        $field = array_merge($defaults, $field);
        $name = "attachments[{$attachment_id}][{$id}]";
        if ($field['input'] == 'hidden') {
            $hidden_fields[$name] = $field['value'];
            continue;
        }
        $required = $field['required'] ? '<span class="alignright"><abbr title="required" class="required">*</abbr></span>' : '';
        $aria_required = $field['required'] ? " aria-required='true' " : '';
        $class = $id;
        $class .= $field['required'] ? ' form-required' : '';
        $item .= "\t\t<tr class='{$class}'>\n\t\t\t<th valign='top' scope='row' class='label'><label for='{$name}'><span class='alignleft'>{$field['label']}</span>{$required}<br class='clear' /></label></th>\n\t\t\t<td class='field'>";
        if (!empty($field[$field['input']])) {
            $item .= $field[$field['input']];
        } elseif ($field['input'] == 'textarea') {
            if (user_can_richedit()) {
                // textarea_escaped when user_can_richedit() = false
                $field['value'] = esc_textarea($field['value']);
            }
            $item .= "<textarea id='{$name}' name='{$name}' {$aria_required}>" . $field['value'] . '</textarea>';
        } else {
            $item .= "<input type='text' class='text' id='{$name}' name='{$name}' value='" . esc_attr($field['value']) . "' {$aria_required} />";
        }
        if (!empty($field['helps'])) {
            $item .= "<p class='help'>" . join("</p>\n<p class='help'>", array_unique((array) $field['helps'])) . '</p>';
        }
        $item .= "</td>\n\t\t</tr>\n";
        $extra_rows = array();
        if (!empty($field['errors'])) {
            foreach (array_unique((array) $field['errors']) as $error) {
                $extra_rows['error'][] = $error;
            }
        }
        if (!empty($field['extra_rows'])) {
            foreach ($field['extra_rows'] as $class => $rows) {
                foreach ((array) $rows as $html) {
                    $extra_rows[$class][] = $html;
                }
            }
        }
        foreach ($extra_rows as $class => $rows) {
            foreach ($rows as $html) {
                $item .= "\t\t<tr><td></td><td class='{$class}'>{$html}</td></tr>\n";
            }
        }
    }
    if (!empty($form_fields['_final'])) {
        $item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n";
    }
    $item .= "\t</tbody>\n";
    $item .= "\t</table>\n";
    foreach ($hidden_fields as $name => $value) {
        $item .= "\t<input type='hidden' name='{$name}' id='{$name}' value='" . esc_attr($value) . "' />\n";
    }
    if ($post->post_parent < 1 && isset($_REQUEST['post_id'])) {
        $parent = (int) $_REQUEST['post_id'];
        $parent_name = "attachments[{$attachment_id}][post_parent]";
        $item .= "\t<input type='hidden' name='{$parent_name}' id='{$parent_name}' value='{$parent}' />\n";
    }
    return $item;
}
Exemple #3
0
/**
 * Get an HTML img element representing an image attachment
 *
 * While $size will accept an array, it is better to register a size with
 * add_image_size() so that a cropped version is generated. It's much more
 * efficient than having to find the closest-sized image and then having the
 * browser scale down the image.
 *
 * @see add_image_size()
 * @uses apply_filters() Calls 'nxt_get_attachment_image_attributes' hook on attributes array
 * @uses nxt_get_attachment_image_src() Gets attachment file URL and dimensions
 * @since 2.5.0
 *
 * @param int $attachment_id Image attachment ID.
 * @param string $size Optional, default is 'thumbnail'.
 * @param bool $icon Optional, default is false. Whether it is an icon.
 * @return string HTML img element or empty string on failure.
 */
function nxt_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = false, $attr = '')
{
    $html = '';
    $image = nxt_get_attachment_image_src($attachment_id, $size, $icon);
    if ($image) {
        list($src, $width, $height) = $image;
        $hwstring = image_hwstring($width, $height);
        if (is_array($size)) {
            $size = join('x', $size);
        }
        $attachment =& get_post($attachment_id);
        $default_attr = array('src' => $src, 'class' => "attachment-{$size}", 'alt' => trim(strip_tags(get_post_meta($attachment_id, '_nxt_attachment_image_alt', true))), 'title' => trim(strip_tags($attachment->post_title)));
        if (empty($default_attr['alt'])) {
            $default_attr['alt'] = trim(strip_tags($attachment->post_excerpt));
        }
        // If not, Use the Caption
        if (empty($default_attr['alt'])) {
            $default_attr['alt'] = trim(strip_tags($attachment->post_title));
        }
        // Finally, use the title
        $attr = nxt_parse_args($attr, $default_attr);
        $attr = apply_filters('nxt_get_attachment_image_attributes', $attr, $attachment);
        $attr = array_map('esc_attr', $attr);
        $html = rtrim("<img {$hwstring}");
        foreach ($attr as $name => $value) {
            $html .= " {$name}=" . '"' . $value . '"';
        }
        $html .= ' />';
    }
    return $html;
}
 /**
  * Returns a random image from one of the blogs on the site.
  *
  * The returned image object, if not null, will have the following properties:
  *
  *     blog_id - the ID of the blog on which the image was posted
  *     title   - the image's title
  *     url     - the absolute URL to the image
  *
  * If the image is associated with a particular post, it will also have
  * the following properties on it:
  *
  *     post_id - the ID of the post that uses the image
  *     user_id - the ID of the user who created a post using the image
  *
  * @return mixed the random image object, or null if none can be found
  *
  * @since 0.1
  */
 public function get_random_image()
 {
     global $blog_id, $nxtdb;
     $current_blog_id = $blog_id;
     $image = null;
     $urls = array();
     // Search through every blog for a usable image.  If an image is found, build
     // the link to it and add a possible caption.
     $blogs = ClassBlogs_Utils::get_all_blog_ids();
     shuffle($blogs);
     foreach ($blogs as $blog) {
         ClassBlogs_NXTClass::switch_to_blog($blog);
         $images = $nxtdb->get_results("\n\t\t\t\tSELECT ID, post_title, GUID FROM {$nxtdb->posts}\n\t\t\t\tWHERE post_mime_type LIKE 'image/%%'\n\t\t\t\tAND post_content <> guid");
         if ($images) {
             $image = $images[array_rand($images)];
             $urls[] = $image->GUID;
             $info = nxt_get_attachment_image_src($image->ID);
             if (!empty($info)) {
                 $image = array('blog_id' => $blog, 'title' => $image->post_title, 'url' => $info[0]);
                 $urls[] = $info[0];
             }
             break;
         }
     }
     ClassBlogs_Utils::restore_blog($current_blog_id);
     // If we have a valid image, try to find the first post on which it was
     // used and add its ID to the image data
     if ($image) {
         $info = array();
         $post_id = null;
         $user_id = null;
         foreach ($urls as $url) {
             $post = $this->_find_first_post_to_use_image($image['blog_id'], $url);
             if (!empty($post)) {
                 break;
             }
         }
         if (!empty($post)) {
             $post_id = $post->ID;
             $user_id = $post->post_author;
         }
         $image['post_id'] = $post_id;
         $image['user_id'] = $user_id;
         $image = (object) $image;
     }
     return $image;
 }
/**
 * Returns width of the Achievement's picture
 *
 * @since 2.0
 * @global DPA_Achievement_Template $achievements_template Achievements template tag object
 * @return int
 */
function dpa_get_achievement_picture_width()
{
    $is_thumbnail = dpa_get_achievement_picture_is_thumbnail();
    $picture_id = dpa_get_achievement_picture_id();
    if ($picture_id < 1) {
        if ($is_thumbnail) {
            $width = apply_filters('dpa_get_achievement_picture_gravatar_width', BP_AVATAR_THUMB_WIDTH, 'thumb');
        } else {
            $width = apply_filters('dpa_get_achievement_picture_gravatar_width', BP_AVATAR_FULL_WIDTH, 'full');
        }
    } else {
        if ($is_thumbnail) {
            $width = apply_filters('dpa_get_achievement_picture_width', BP_AVATAR_THUMB_WIDTH, 'thumb');
        } else {
            list($url, $width, $height) = nxt_get_attachment_image_src($picture_id, 'full');
            $width = apply_filters('dpa_get_achievement_picture_width', $width, 'full');
        }
    }
    return apply_filters('dpa_get_achievement_picture_width', $width);
}
 $html = '';
 $rel = 'lightbox';
 // Get the other images.
 $images = woo_get_post_images(0, 'full');
 if (count($images) > 0) {
     $rel = 'lightbox[' . $post->ID . ']';
 }
 // Store featured image ID for exclusion
 if (isset($woo_options['woo_post_image_support']) && $woo_options['woo_post_image_support'] == 'true' && current_theme_supports('post-thumbnails') && function_exists('get_post_thumbnail_id')) {
     $featured_image_id = get_post_thumbnail_id($post->ID);
 } else {
     $featured_image_id = '';
 }
 if ($featured_image_id != '') {
     $html .= '<div class="portfolio-item single-portfolio-image ">';
     $image_data = nxt_get_attachment_image_src($featured_image_id, 'full');
     $image_url = $image_data[0];
     $html .= '<a href="' . $image_url . '" rel="' . $rel . '">' . woo_image($args) . '</a>' . "\n";
     $html .= '</div>';
 }
 if (count($images) > 0) {
     foreach ($images as $k => $v) {
         $pos = false;
         // Skip if the image is used as the posts featured image
         if ($featured_image_id == $v['id']) {
             continue;
         }
         if (isset($image_url) && $image_url != '' && $v['url'] != '') {
             $pos = strpos($v['url'], $image_url);
         }
         if ($pos === false || $v['url'] != $image_url) {
Exemple #7
0
    /**
     * The styles for the post thumbnails / custom page headers.
     *
     * Referenced via add_custom_image_header() in bp_dtheme_setup().
     *
     * @global nxt_Query $post The current nxt_Query object for the current post or page
     * @since 1.2
     */
    function bp_dtheme_header_style()
    {
        global $post;
        $header_image = '';
        if (is_singular() && current_theme_supports('post-thumbnails') && has_post_thumbnail($post->ID)) {
            $image = nxt_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'post-thumbnail');
            // $src, $width, $height
            if (!empty($image) && $image[1] >= HEADER_IMAGE_WIDTH) {
                $header_image = $image[0];
            }
        } else {
            $header_image = get_header_image();
        }
        ?>

	<style type="text/css">
		<?php 
        if (!empty($header_image)) {
            ?>
			#header { background-image: url(<?php 
            echo $header_image;
            ?>
); }
		<?php 
        }
        ?>

		<?php 
        if ('blank' == get_header_textcolor()) {
            ?>
		#header h1, #header #desc { display: none; }
		<?php 
        } else {
            ?>
		#header h1 a, #desc { color:#<?php 
            header_textcolor();
            ?>
; }
		<?php 
        }
        ?>
	</style>

<?php 
    }
 /**
  */
 public function get_image_src($size = 'thumbnail', $attach_id = null)
 {
     // attach id was passed?
     if (empty($attach_id)) {
         $attach_id = $this->get();
     }
     // src is null by default
     $src = null;
     // did we get an attachement id?
     if (is_numeric($attach_id)) {
         // try to get the attachment info
         $src = nxt_get_attachment_image_src($attach_id, $size);
     } else {
         // was a default set?
         if (isset($this->default_value)) {
             // use default
             $directive = $this->directive()->get('default_value');
             // mimic the src array
             $src = array_fill(0, 3, null);
             // is a default set?
             if ($directive->has_value()) {
                 $src[0] = ICE_Files::theme_file_url($directive->get_theme(), $directive->get_value());
             }
         }
     }
     // did we find one?
     if (is_array($src)) {
         return $src;
     } else {
         return false;
     }
 }
 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 = $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 = nxt_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
     $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';
     }
     // Check for a custom description.
     $description = get_post_meta($id, 'lightbox-description', true);
     if ($description != '') {
         $settings['caption'] = $description;
     }
     // Allow child themes/plugins to filter these settings.
     $settings = apply_filters('woo_portfolio_item_settings', $settings, $id);
     return $settings;
 }
 function woo_get_post_images($offset = 1, $size = 'large')
 {
     // Arguments
     $repeat = 100;
     // Number of maximum attachments to get
     $photo_size = 'large';
     // The nxt "size" to use for the large image
     global $post;
     $output = array();
     $id = get_the_id();
     $attachments = get_children(array('post_parent' => $id, 'numberposts' => $repeat, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order date'));
     if (!empty($attachments)) {
         $output = array();
         $count = 0;
         foreach ($attachments as $att_id => $attachment) {
             $count++;
             if ($count <= $offset) {
                 continue;
             }
             $url = nxt_get_attachment_image_src($att_id, $photo_size, true);
             $output[] = array('url' => $url[0], 'caption' => $attachment->post_excerpt, 'id' => $att_id);
         }
     }
     return $output;
 }
 /**
  * Handle an Image upload for the background image.
  *
  * @since 3.0.0
  */
 function handle_upload()
 {
     if (empty($_FILES)) {
         return;
     }
     check_admin_referer('custom-background-upload', '_nxtnonce-custom-background-upload');
     $overrides = array('test_form' => false);
     $file = nxt_handle_upload($_FILES['import'], $overrides);
     if (isset($file['error'])) {
         nxt_die($file['error']);
     }
     $url = $file['url'];
     $type = $file['type'];
     $file = $file['file'];
     $filename = basename($file);
     // Construct the object array
     $object = array('post_title' => $filename, 'post_content' => $url, 'post_mime_type' => $type, 'guid' => $url, 'context' => 'custom-background');
     // Save the data
     $id = nxt_insert_attachment($object, $file);
     // Add the meta-data
     nxt_update_attachment_metadata($id, nxt_generate_attachment_metadata($id, $file));
     update_post_meta($id, '_nxt_attachment_is_custom_background', get_option('stylesheet'));
     set_theme_mod('background_image', esc_url($url));
     $thumbnail = nxt_get_attachment_image_src($id, 'thumbnail');
     set_theme_mod('background_image_thumb', esc_url($thumbnail[0]));
     do_action('nxt_create_file_in_uploads', $file, $id);
     // For replication
     $this->updated = true;
 }
 function vt_resize($attach_id = null, $img_url = null, $width, $height, $crop = false)
 {
     // this is an attachment, so we have the ID
     if ($attach_id) {
         $image_src = nxt_get_attachment_image_src($attach_id, 'full');
         $file_path = get_attached_file($attach_id);
         // this is not an attachment, let's use the image url
     } else {
         if ($img_url) {
             $file_path = parse_url($img_url);
             $file_path = $_SERVER['DOCUMENT_ROOT'] . $file_path['path'];
             //$file_path = ltrim( $file_path['path'], '/' );
             //$file_path = rtrim( ABSPATH, '/' ).$file_path['path'];
             $orig_size = getimagesize($file_path);
             $image_src[0] = $img_url;
             $image_src[1] = $orig_size[0];
             $image_src[2] = $orig_size[1];
         }
     }
     $file_info = pathinfo($file_path);
     // check if file exists
     $base_file = $file_info['dirname'] . '/' . $file_info['filename'] . '.' . $file_info['extension'];
     if (!file_exists($base_file)) {
         return;
     }
     $extension = '.' . $file_info['extension'];
     // the image path without the extension
     $no_ext_path = $file_info['dirname'] . '/' . $file_info['filename'];
     $cropped_img_path = $no_ext_path . '-' . $width . 'x' . $height . $extension;
     // checking if the file size is larger than the target size
     // if it is smaller or the same size, stop right here and return
     if ($image_src[1] > $width) {
         // the file is larger, check if the resized version already exists (for $crop = true but will also work for $crop = false if the sizes match)
         if (file_exists($cropped_img_path)) {
             $cropped_img_url = str_replace(basename($image_src[0]), basename($cropped_img_path), $image_src[0]);
             $vt_image = array('url' => $cropped_img_url, 'width' => $width, 'height' => $height);
             return $vt_image;
         }
         // $crop = false or no height set
         if ($crop == false or !$height) {
             // calculate the size proportionaly
             $proportional_size = nxt_constrain_dimensions($image_src[1], $image_src[2], $width, $height);
             $resized_img_path = $no_ext_path . '-' . $proportional_size[0] . 'x' . $proportional_size[1] . $extension;
             // checking if the file already exists
             if (file_exists($resized_img_path)) {
                 $resized_img_url = str_replace(basename($image_src[0]), basename($resized_img_path), $image_src[0]);
                 $vt_image = array('url' => $resized_img_url, 'width' => $proportional_size[0], 'height' => $proportional_size[1]);
                 return $vt_image;
             }
         }
         // check if image width is smaller than set width
         $img_size = getimagesize($file_path);
         if ($img_size[0] <= $width) {
             $width = $img_size[0];
         }
         // Check if GD Library installed
         if (!function_exists('imagecreatetruecolor')) {
             echo 'GD Library Error: imagecreatetruecolor does not exist - please contact your webhost and ask them to install the GD library';
             return;
         }
         // no cache files - let's finally resize it
         $new_img_path = image_resize($file_path, $width, $height, $crop);
         $new_img_size = getimagesize($new_img_path);
         $new_img = str_replace(basename($image_src[0]), basename($new_img_path), $image_src[0]);
         // resized output
         $vt_image = array('url' => $new_img, 'width' => $new_img_size[0], 'height' => $new_img_size[1]);
         return $vt_image;
     }
     // default output - without resizing
     $vt_image = array('url' => $image_src[0], 'width' => $width, 'height' => $height);
     return $vt_image;
 }
 function print_thumbnail($thumbnail = '', $use_timthumb = true, $alttext = '', $width = 100, $height = 100, $class = '', $echoout = true, $forstyle = false, $resize = true, $post = '')
 {
     global $shortname;
     if ($post == '') {
         global $post;
     }
     $output = '';
     $thumbnail_orig = $thumbnail;
     $thumbnail = et_multisite_thumbnail($thumbnail);
     $cropPosition = '';
     $allow_new_thumb_method = false;
     if ($use_timthumb === true) {
         $new_method = true;
         $new_method_thumb = '';
         $external_source = false;
         $allow_new_thumb_method = !$external_source && $new_method && $cropPosition == '';
         if ($allow_new_thumb_method && $thumbnail != '') {
             $et_crop = get_post_meta($post->ID, 'et_nocrop', true) == '' ? true : false;
             $new_method_thumb = et_resize_image(et_path_reltoabs($thumbnail), $width, $height, $et_crop);
             if (is_nxt_error($new_method_thumb)) {
                 $new_method_thumb = '';
             }
         }
     }
     if ($forstyle === false) {
         if ($use_timthumb === false) {
             $output = $thumbnail_orig;
         } else {
             $output = '<img src="' . $new_method_thumb . '"';
             if ($class != '') {
                 $output .= " class='{$class}' ";
             }
             $output .= " alt='{$alttext}' width='{$width}' height='{$height}' />";
             if (!$resize) {
                 $output = $thumbnail;
             }
         }
     } else {
         if ($use_timthumb === false) {
             $et_featured_image = nxt_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
             $output = $et_featured_image[0];
         } else {
             $output = $new_method_thumb;
         }
     }
     if ($echoout) {
         echo $output;
     } else {
         return $output;
     }
 }
j_mail("Facebook Autologin", "Post " . $_REQUEST['p'] . " requires login: Showing Facebook prompt (Referrer: " . $_SERVER['HTTP_REFERER'] . ")");
/******************Template for "AutoLogin" Page******************/
get_header();
//get_sidebar();
echo '<div id="main-col"><div id="content" class="post">';
//Output Facebook Javascript to immediately show a login prompt to the user
//Note: The FB api is already initialized via nxt_footer, so I don't need to
//call jfb_output_facebook_init() again - I just create another login callback, this time which
//redirects to the destination post instead of back to the current page.
jfb_output_facebook_callback(get_permalink($post->ID), "autologin_callback");
jfb_output_facebook_instapopup("autologin_callback");
//Show the user a message.  Since the post is private and the user isn't yet logged in, you can
//use your discretion as to what information you reveal about the destination post.
if (function_exists('gallery_pg_id') && $post->post_parent == gallery_pg_id()) {
    echo "<h2>{$post->post_title}</h2><br />This photo album is private and requires login.  A Facebook Connect window should popup in a moment.<br /><br />";
} else {
    echo "<h2>Login Required</h2><br />This post is private and requires login.  A Facebook Connect window should popup in a moment.<br /><br />";
}
//If the destination post has a thumbnail, show it (sizing it down if it's too wide)
if (has_post_thumbnail($post->ID)) {
    $thumb = nxt_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'medium');
    $maxWd = 590;
    if ($thumb[1] > $maxWd) {
        $thumb[2] = $maxWd * ($thumb[2] / $thumb[1]);
        $thumb[1] = $maxWd;
    }
    echo '<div style="text-align:center;"><img alt="preview" src="' . $thumb[0] . '" height="' . $thumb[2] . '" width="' . $thumb[1] . '" /></div>';
}
echo "</div></div>";
get_footer();
/******************Template for "AutoLogin" Page******************/