1
I am editing the theme for wordpress http://www.arrastheme.com/ but a problem has arisen.
My images are hosted on picasa and linked in the post.
The images do not appear in the home or in the archives, only when it enters inside the post is possible candles.
I tried through these 2 tutorials to make the image appear, but without success
Tutorials:
http://www.wprecipes.com/how-to-get-the-first-image-from-the-post-and-display-it
http://css-tricks.com/snippets/wordpress/get-the-first-image-from-a-post/
The script related to the images is this:
<?php
/**
* Containers for storing thumbnail types and its default sizes.
* @since 1.4.4
*/
$arras_image_sizes = array();
function arras_add_default_thumbnails() {
$single_thumbs = arras_get_single_thumbs_size();
arras_add_image_size( 'single-thumb', __('Single Post Thumbnail', 'arras'), $single_thumbs[0], $single_thumbs[1] );
arras_add_image_size( 'sidebar-thumb', __('Sidebar Widgets', 'arras'), 36, 36);
do_action('arras_add_default_thumbnails');
}
/**
* Function to add image size into both theme system.
* @since 1.4.4
*/
function arras_add_image_size($id, $name, $default_width, $default_height) {
global $arras_image_sizes;
$arras_custom_image_sizes = arras_get_option('custom_thumbs');
// Check from options if a custom width and height has been specified, else use defaults
if (isset($arras_custom_image_sizes[$id])) {
$width = $arras_custom_image_sizes[$id]['w'];
$height = $arras_custom_image_sizes[$id]['h'];
} else {
$width = $default_width;
$height = $default_height;
}
$arras_image_sizes[$id] = array(
'name' => $name,
'w' => $width,
'h' => $height,
'dw' => $default_width,
'dh' => $default_height
);
add_image_size($id, $width, $height, true);
}
/**
* Function to remove image size into both theme system.
* @since 1.4.4
*/
function arras_remove_image_size($id) {
global $arras_image_sizes, $_wp_additional_image_sizes;
unset($arras_images_sizes[$id]);
unset($_wp_additional_image_sizes[$id]);
}
/**
* Function to get image size's name, width and height, default or custom.
* @since 1.4.4
*/
function arras_get_image_size($id) {
global $arras_image_sizes;
return (isset($arras_image_sizes[$id])) ? $arras_image_sizes[$id] : false;
}
/**
* Helper function to grab and display thumbnail from specified post
* @since 1.4.0
*/
function arras_get_thumbnail($size = 'thumbnail', $id = NULL) {
global $post, $arras_image_sizes;
$empty_thumbnail = '<img src="' . get_bloginfo('template_directory') . '/images/thumbnail.png" alt="' . get_the_excerpt() . '" title="' . get_the_title() . '" />';
if ($post) $id = $post->ID;
// get post thumbnail (WordPress 2.9)
if (function_exists('has_post_thumbnail')) {
if (has_post_thumbnail($id)) {
return get_the_post_thumbnail( $id, $size, array(
'alt' => get_the_excerpt(),
'title' => get_the_title()
) );
} else {
// Could it be an attachment?
if ($post->post_type == 'attachment') {
return wp_get_attachment_image( $id, $size, false, array(
'alt' => get_the_excerpt(),
'title' => get_the_title()
) );
}
// Use first thumbnail if auto thumbs is enabled.
if (arras_get_option('auto_thumbs')) {
$img_id = arras_get_first_post_image_id();
if (!$img_id) return $empty_thumbnail;
return wp_get_attachment_image($img_id, $size, false, array(
'alt' => get_the_excerpt(),
'title' => get_the_title()
) );
}
}
}
// go back to legacy (phpThumb or timThumb)
$thumbnail = get_post_meta($id, ARRAS_POST_THUMBNAIL, true);
$w = $arras_image_sizes[$size]['w'];
$h = $arras_image_sizes[$size]['h'];
if ($thumbnail != '') {
if (!$arras_image_sizes[$size]) return false;
return '<img src="' . get_bloginfo('template_directory') . '/library/timthumb.php?src=' . arras_timthumb_wpmu_image_src($thumbnail) . '&w=' . $w . '&h=' . $h . '&zc=1" alt="' . get_the_excerpt() . '" title="' . get_the_title() . '" />';
} else if (arras_get_option('auto_thumbs')) {
if (!$arras_image_sizes[$size]) return false;
$img_id = arras_get_first_post_image_id();
if (!$img_id) return $empty_thumbnail;
$image = wp_get_attachment_image_src($img_id, 'full', false);
if ($image) {
list($src, $width, $height) = $image;
return '<img src="' . get_bloginfo('template_directory') . '/library/timthumb.php?src=' . arras_timthumb_wpmu_image_src($src) . '&w=' . $w . '&h=' . $h . '&zc=1" alt="' . get_the_excerpt() . '" title="' . get_the_title() . '" />';
}
}
return $empty_thumbnail;
}
/**
* Function to convert image URLs into WPMU compatible URLs for Timthumb
* @since 1.5.1
*/
function arras_timthumb_wpmu_image_src($url) {
global $blog_id, $current_site;
$uploads = wp_upload_dir();
if ( isset($blog_id) && $blog_id > 0 ) {
$split = explode( '/files/', $url);
if ( isset($split[1]) ) {
$url = 'http://' . $current_site->domain . $current_site->path . 'wp-content/blogs.dir/' . $blog_id . '/files/' . $split[1];
}
}
return $url;
}
/**
* Function to retrieve the first image ID from post.
* @since 1.5.0
*/
function arras_get_first_post_image_id($id = NULL) {
global $post;
if (!$id) $id = $post->ID;
$attachments = get_children('post_parent=' . $id . '&post_type=attachment&post_mime_type=image');
if (!$attachments) return false;
$keys = array_reverse(array_keys($attachments));
return $keys[0];
}
function arras_get_single_thumbs_size() {
$layout = arras_get_option('layout');
if ( strpos($layout, '1c') !== false ) {
$size = array(930, 375);
} else if ( strpos($layout, '3c') !== false ) {
$size = array(465, 190);
} else {
$size = array(620, 300);
}
return apply_filters('arras_content_width', $size);
}
/* End of file thumbnails.php */
/* Location: ./library/thumbnails.php */