Forum Replies Created

Viewing 15 replies - 1 through 15 (of 18 total)
  • Thread Starter chevy454

    (@chevy454)

    Awesome, thanks for the direction! I also had to remove the else statement in content.php as it was doing the same thing on the main blog roll page.

    Thread Starter chevy454

    (@chevy454)

    *bump*

    Thread Starter chevy454

    (@chevy454)

    Ok, so I’ve been working most of the day on this…I added the code below, and it’s at least pulling the correct number of images attached to the post, but for some reason it won’t/can’t display them?

    $post_subtitrare = get_post( $post->ID );
        $content = $post_subtitrare->post_content;
        $pattern = get_shortcode_regex();
        preg_match( "/$pattern/s", $content, $match );
        if( isset( $match[2] ) && ( "gallery" == $match[2] ) ) {
            $atts = shortcode_parse_atts( $match[3] );
            $images = isset( $atts['ids'] ) ? explode( ',', $atts['ids'] ) : get_children( 'post_type=attachment&post_mime_type=image&post_parent=' . $post->ID .'&order=ASC&orderby=menu_order ID' );

    A view source reveals that none of the image info is being fed to the browser, other than the size & placement [size is wrong on top image, Internet Explorer displays the empty images with the red X but FireFox just skips ’em].

    Page url: http://www.vintagepowertrain.com/lkjdkfljdklfj/

    Goodies from my functions.php:

    ////custom gallery
    
    function wpo_get_images(
    	$size = 'thumbnail',
    	$limit = '0',
    	$offset = '0',
    	$big = 'large',
    	$post_id = '$post->ID',
    	$link = '1',
    	$img_class = 'attachment-image',
    	$wrapper = 'div',
    	$wrapper_class = 'attachment-image-wrapper') {
    	global $post;
    
        $post_subtitrare = get_post( $post->ID );
        $content = $post_subtitrare->post_content;
        $pattern = get_shortcode_regex();
        preg_match( "/$pattern/s", $content, $match );
        if( isset( $match[2] ) && ( "gallery" == $match[2] ) ) {
            $atts = shortcode_parse_atts( $match[3] );
            $images = isset( $atts['ids'] ) ? explode( ',', $atts['ids'] ) : get_children( 'post_type=attachment&post_mime_type=image&post_parent=' . $post->ID .'&order=ASC&orderby=menu_order ID' );
    
    		$num_of_images = count($images);
    
    		if ($offset > 0) : $start = $offset--; else : $start = 0; endif;
    		if ($limit > 0) : $stop = $limit+$start; else : $stop = $num_of_images; endif;
    
    		$i = 0;
    
    		foreach ($images as $attachment_id => $image) {
    			if ($start <= $i and $i < $stop) {
    			$img_title = $image->post_title;   // title.
    			$img_description = $image->post_content; // description.
    			$img_caption = $image->post_excerpt; // caption.
    			//$img_page = get_permalink($image->ID); // The link to the attachment page.
    			$img_alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true);
    			if ($img_alt == '') {
    			$img_alt = $img_title;
    			}
    				if ($big == 'large') {
    				$big_array = image_downsize( $image->ID, $big );
     				$img_url = $big_array[0]; // large.
    				} else {
    				$img_url = wp_get_attachment_url($image->ID); // url of the full size image.
    				}
    
    			// FIXED to account for non-existant thumb sizes.
    			$preview_array = image_downsize( $image->ID, $size );
    			if ($preview_array[3] != 'true') {
    			$preview_array = image_downsize( $image->ID, 'thumbnail' );
     			$img_preview = $preview_array[0]; // thumbnail or medium image to use for preview.
     			$img_width = $preview_array[1];
     			$img_height = $preview_array[2];
    			} else {
     			$img_preview = $preview_array[0]; // thumbnail or medium image to use for preview.
     			$img_width = $preview_array[1];
     			$img_height = $preview_array[2];
     			}
     			// End FIXED to account for non-existant thumb sizes.
    
     			///////////////////////////////////////////////////////////
    			// This is where you'd create your custom image/link/whatever tag using the variables above.
    			// This is an example of a basic image tag using this method.
    			?>
    			<?php if ($wrapper != '0') : ?>
    			<<?php echo $wrapper; ?> class="<?php echo $wrapper_class; ?>">
    			<?php endif; ?>
    			<?php if ($link == '1') : ?>
    			<a href="<?php echo $img_url; ?>" title="<?php echo $img_title; ?>">
    			<?php endif; ?>
    			<img class="<?php echo $img_class; ?>" src="<?php echo $img_preview; ?>" alt="<?php echo $img_alt; ?>" title="<?php echo $img_title; ?>" />
    			<?php if ($link == '1') : ?>
    			</a>
    			<?php endif; ?>
    			<?php if ($img_caption != '') : ?>
    			<div class="attachment-caption"><?php echo $img_caption; ?></div>
    			<?php endif; ?>
    			<?php if ($img_description != '') : ?>
    			<div class="attachment-description"><?php echo $img_description; ?></div>
    			<?php endif; ?>
    			<?php if ($wrapper != '0') : ?>
    			</<?php echo $wrapper; ?>>
    			<?php endif; ?>
    			<?php
    			// End custom image tag. Do not edit below here.
    			///////////////////////////////////////////////////////////
    
    			}
    			$i++;
    		}
    
    	}
    }

    Thread Starter chevy454

    (@chevy454)

    I think I’m closer but I’m not sure…now the page returns all of the images contained within the entire media gallery, versus only the ones attached to this specific post’s gallery. It’s formatting it correctly, with the larger image above the content and the thumbnails below the content, but there are only 3 images attached to that post.

    Page url: http://www.vintagepowertrain.com/lkjdkfljdklfj/

    Here’s the code I have now:

    function wpo_get_images(
    	$size = 'thumbnail',
    	$limit = '0',
    	$offset = '0',
    	$big = 'large',
    	$post_id = '$post->ID',
    	$link = '1',
    	$img_class = 'attachment-image',
    	$wrapper = 'div',
    	$wrapper_class = 'attachment-image-wrapper') {
    	global $post;
    
    	$images = get_children( array(
    	'post_parent' => $post->id,
    	'post_status' => 'inherit',
    	'post_type' => 'attachment',
    	'post_mime_type' => 'image',
    	'order' => '',
    	'orderby' => 'menu_order ID')
    	);
    
    	if ($images) {
    
    		$num_of_images = count($images);
    
    		if ($offset > 0) : $start = $offset--; else : $start = 0; endif;
    		if ($limit > 0) : $stop = $limit+$start; else : $stop = $num_of_images; endif;
    
    		$i = 0;
    		preg_match('/\[gallery.*ids=.(.*).\]/', $post_content, $ids);
    		$attachment_ids = explode(",", $ids[1]);
    		foreach ($images as $attachment_id => $image) {
    			if ($start <= $i and $i < $stop) {
    			$img_title = $image->post_title;   // title.
    			$img_description = $image->post_content; // description.
    			$img_caption = $image->post_excerpt; // caption.
    			//$img_page = get_permalink($image->ID); // The link to the attachment page.
    			$img_alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true);
    			if ($img_alt == '') {
    			$img_alt = $img_title;
    			}
    				if ($big == 'large') {
    				$big_array = image_downsize( $image->ID, $big );
     				$img_url = $big_array[0]; // large.
    				} else {
    				$img_url = wp_get_attachment_url($image->ID); // url of the full size image.
    				}
    
    			// FIXED to account for non-existant thumb sizes.
    			$preview_array = image_downsize( $image->ID, $size );
    			if ($preview_array[3] != 'true') {
    			$preview_array = image_downsize( $image->ID, 'thumbnail' );
     			$img_preview = $preview_array[0]; // thumbnail or medium image to use for preview.
     			$img_width = $preview_array[1];
     			$img_height = $preview_array[2];
    			} else {
     			$img_preview = $preview_array[0]; // thumbnail or medium image to use for preview.
     			$img_width = $preview_array[1];
     			$img_height = $preview_array[2];
     			}
     			// End FIXED to account for non-existant thumb sizes.
    
     			///////////////////////////////////////////////////////////
    			// This is where you'd create your custom image/link/whatever tag using the variables above.
    			// This is an example of a basic image tag using this method.
    			?>
    			<?php if ($wrapper != '0') : ?>
    			<<?php echo $wrapper; ?> class="<?php echo $wrapper_class; ?>">
    			<?php endif; ?>
    			<?php if ($link == '1') : ?>
    			<a href="<?php echo $img_url; ?>" title="<?php echo $img_title; ?>">
    			<?php endif; ?>
    			<img class="<?php echo $img_class; ?>" src="<?php echo $img_preview; ?>" alt="<?php echo $img_alt; ?>" title="<?php echo $img_title; ?>" />
    			<?php if ($link == '1') : ?>
    			</a>
    			<?php endif; ?>
    			<?php if ($img_caption != '') : ?>
    			<div class="attachment-caption"><?php echo $img_caption; ?></div>
    			<?php endif; ?>
    			<?php if ($img_description != '') : ?>
    			<div class="attachment-description"><?php echo $img_description; ?></div>
    			<?php endif; ?>
    			<?php if ($wrapper != '0') : ?>
    			</<?php echo $wrapper; ?>>
    			<?php endif; ?>
    			<?php
    			// End custom image tag. Do not edit below here.
    			///////////////////////////////////////////////////////////
    
    			}
    			$i++;
    		}
    
    	}
    }
    Thread Starter chevy454

    (@chevy454)

    Prior to my 3.5 upgrade, the below code rendered a page like so:

    single.php
    
            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    	xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    	x First image attached to post, large size x
    	xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    	xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    
    	--------------> Output of content box <--------------
    
    xxxxxxxxxxxxxxxxxxxxxxxxxxxx  xxxxxxxxxxxxxxxxxxxxxxxxxxxx
    x second image, thumbnail  x  x third image, thumbnail   x
    xxxxxxxxxxxxxxxxxxxxxxxxxxxx  xxxxxxxxxxxxxxxxxxxxxxxxxxxx

    All the user had to do was hit “Add media”, upload whatever images he wanted displayed in the post [products, in this case], set the order of the images with the first image being the top/full size image, and then type his description in the text field, and when he hit submit it spit out the above all nicely formatted.

    This was the code in single.php:

    <div class="entry-content">
                        <div id="top-image"><?php wpo_get_images('large','1','0','large',"$post->ID",'1','feat-img','div','main-thumb'); ?></div>
                        <?php the_content(); ?>
                            <div class="outer-element">
                                    <?php wpo_get_images('thumbnail','0','1','large',"$post->ID",'1','bot-thumbs','div','inner-element'); ?>
                            </div>
                    </div>

    And this was what was in my functions.php:

    // Add the ability to use post thumbnails if it isn't already enabled.
    // Not required. Use only of you want to have more than the large,
    // medium or thumbnail options WP uses by default.
    
    if ( function_exists( 'add_image_size' ) ) add_theme_support( 'post-thumbnails' );
    
    // Add custom thumbnail sizes to your theme. These sizes will be auto-generated
    // by the media manager when adding images to it on a new post.
    if ( function_exists( 'add_image_size' ) ) {
        add_image_size( 't1x1', 145, 200, true );
        add_image_size( 't2x1', 307, 200, true );
        add_image_size( 't2x2', 307, 417, true );
    }
    
    ///////////////////////////////////////////////
    //
    // Start WPOutfitters.com Custom Gallery Function
    //
    //////////////////////////////////////////////
    
    function wpo_get_images($size = 'thumbnail', $limit = '0', $offset = '0', $big = 'large', $post_id = '$post->ID', $link = '1', $img_class = 'attachment-image', $wrapper = 'div', $wrapper_class = 'attachment-image-wrapper') {
        global $post;
    
        $images = get_children( array('post_parent' => $post_id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
    
        if ($images) {
    
            $num_of_images = count($images);
    
            if ($offset > 0) : $start = $offset--; else : $start = 0; endif;
            if ($limit > 0) : $stop = $limit+$start; else : $stop = $num_of_images; endif;
    
            $i = 0;
            foreach ($images as $attachment_id => $image) {
                if ($start <= $i and $i < $stop) {
                $img_title = $image->post_title;   // title.
                $img_description = $image->post_content; // description.
                $img_caption = $image->post_excerpt; // caption.
                //$img_page = get_permalink($image->ID); // The link to the attachment page.
                $img_alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true);
                if ($img_alt == '') {
                $img_alt = $img_title;
                }
                    if ($big == 'large') {
                    $big_array = image_downsize( $image->ID, $big );
                    $img_url = $big_array[0]; // large.
                    } else {
                    $img_url = wp_get_attachment_url($image->ID); // url of the full size image.
                    }
    
                // FIXED to account for non-existant thumb sizes.
                $preview_array = image_downsize( $image->ID, $size );
                if ($preview_array[3] != 'true') {
                $preview_array = image_downsize( $image->ID, 'thumbnail' );
                $img_preview = $preview_array[0]; // thumbnail or medium image to use for preview.
                $img_width = $preview_array[1];
                $img_height = $preview_array[2];
                } else {
                $img_preview = $preview_array[0]; // thumbnail or medium image to use for preview.
                $img_width = $preview_array[1];
                $img_height = $preview_array[2];
                }
                // End FIXED to account for non-existant thumb sizes.
    
                ///////////////////////////////////////////////////////////
                // This is where you'd create your custom image/link/whatever tag using the variables above.
                // This is an example of a basic image tag using this method.
                ?>
                <?php if ($wrapper != '0') : ?>
                <<?php echo $wrapper; ?> class="<?php echo $wrapper_class; ?>">
                <?php endif; ?>
                <?php if ($link == '1') : ?>
                <a href="<?php echo $img_url; ?>" title="<?php echo $img_title; ?>">
                <?php endif; ?>
                <img class="<?php echo $img_class; ?>" src="<?php echo $img_preview; ?>" alt="<?php echo $img_alt; ?>" title="<?php echo $img_title; ?>" />
                <?php if ($link == '1') : ?>
                </a>
                <?php endif; ?>
                <?php if ($img_caption != '') : ?>
                <div class="attachment-caption"><?php echo $img_caption; ?></div>
                <?php endif; ?>
                <?php if ($img_description != '') : ?>
                <div class="attachment-description"><?php echo $img_description; ?></div>
                <?php endif; ?>
                <?php if ($wrapper != '0') : ?>
                </<?php echo $wrapper; ?>>
                <?php endif; ?>
                <?php
                // End custom image tag. Do not edit below here.
                ///////////////////////////////////////////////////////////
    
                }
                $i++;
            }
    
        }
    }

    I’ve read 3.5 handles the media attachment ID’s different, which is obviously where I’m encountering the trouble. I’ve tried a few things from the codex and google and either get errors or no change…but I’ve ran across several other people having issues with the 3.5 update in regards to custom galleries.

    Am I overthinking this and simply need to recode for the new shortcode, or does my above code look fixable without too much hassle? I thought the above worked pretty slick, as did my friend who I did the site for…

    Thread Starter chevy454

    (@chevy454)

    Doing a view source it looks like after the update it’s not adding the class or other styling attributes from the custom gallery code…I’ve read through the 3.5 info, but I’m not exactly sure what to look for or what I’m missing…anyone have any ideas?

    Here’s a before page: http://www.vintagepowertrain.com/fomoco-test/

    And an after: http://www.vintagepowertrain.com/glide-your-turbo-400/

    Since the update doesn’t touch anything in your specific theme file is it safe to assume the breakage is due to how the new gallery is added to posts versus the old way?

    Just curious, exactly what was your media library issue?

    Thread Starter chevy454

    (@chevy454)

    Anyone have a suggestion or even a direction to look?

    Thread Starter chevy454

    (@chevy454)

    Anyone? Is this a styling problem, a problem with my search widget, perhaps a missing file or template, ????

    Thread Starter chevy454

    (@chevy454)

    Here’s what it looks like when you search for “test”:

    http://www.claryfuneralhome.com/r4/articles/?s=test

    [quote]I am tired of using dumb tricks like copy pasting into notepad, and then back into the visual editor,[/quote]
    I tried this and it didn’t work…what’s the trick? I’m setting a WP site up for a client specifically because they don’t want to have to mess with any html, and this isn’t helping.

    BTW, I agree with everyone else, this issue with line breaks SUCKS…

    Thread Starter chevy454

    (@chevy454)

    Ok, .post got it Rev, thanks!

    I’m using a chopped/screwed stylesheet, so was working in the dark.

    Thread Starter chevy454

    (@chevy454)

    Duh, forgot the url to the test site: http://www.claryfuneralhome.com/r4/articles/

    Thread Starter chevy454

    (@chevy454)

    I was making this waaaay to hard! It finally hit me to simply cut out anything in my sidebar, making sidebar.php simply an opening and closing div basically, adding the appropriate before/after comments in functions.php, and then pasting the items that were previously on my hard coded sidebar (custom side navigation menu and a scrolling iframe element) into custom text widgets. Easy peasy and took a whopping 5 minutes once it dawned on me…!

    Thanks for the nudges in the right direction!!

    Thread Starter chevy454

    (@chevy454)

    Ok, let’s try this again…here is my sidebar.php:

    http://wordpress.pastebin.com/24AqF8s0

Viewing 15 replies - 1 through 15 (of 18 total)