September 20, 201016 yr Hello, I am a bit stuck on getting an image to show. I want an image (thumbnail) to be set via Featured Image. Easy. Next, I want to be able to click on the image and get the original, full size image to appear...Not so easy. Can anyone help me with this? here is my code: <a class="fancybox" title="<?php the_title(); ?>" href="???????"><?php the_post_thumbnail( 'artwork-thumbnail' ); ?></a> Cheers
September 22, 201016 yr Author If someone can help me with this, I am willing to pay £10. I am totally stuck and have tried several different approaches with no luck, I am not a PHP expert so that doesn't help! Basically, I need a dynamic way of calling the original size image when the thumbnail is clicked on, and maybe (if poss), to make it so that it's not over 800px wide. As if the user uploads a very large image, then that would be no good when blown up full size! If someone could let me know if they can do this, I'd be very happy man! I can give you access via FTP to do this. Here is the page so you can get an idea whats going on: My link Huw
September 22, 201016 yr Would love to help - but you know my Wordpress / PHP knowledge! Hope you get it sorted Gem
September 22, 201016 yr Author Are you using a custom field for the image URI? I am using the 'Featured Image', section of a custom post. And the post_thumbnail snippet to display it. I didn't want to use custom fields to make this site as easy as possible as the client (my auntie!) isn't very tech savvy, at all!
September 30, 201016 yr I think your hyperlink needs some work. You want it set up so that the hyperlink calls the image that you've uploaded, so you need to work out how Wordpress stores the images that you're uploading. I think the default is in date and time folders, so your link will be something like this: <a href="http://www.yourdomain.com/wp-content/uploads/<?php the_time('Y') ?>/<?php the_time('m') ?>/<?php the_title(); ?>.jpg" class "fancybox"></a> Will take a bit of fiddling, but I hope that helps.
October 6, 201016 yr Use this instead. In functions.php add if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9 add_theme_support( 'post-thumbnails' ); add_image_size( 'artwork-thumbnail', 171, 171, true ); } function artwork-thumbnail-image(){ if ( has_post_thumbnail() ) { the_post_thumbnail( 'artwork-thumbnail', array('class' => 'postim') ); } else {?> <img class="postim" src="<?php bloginfo('template_directory'); ?>/images/defaultthumb.gif" alt="" /> <?php }; } Modify defaultthumb.gif to your default image which you want to show when their is no image uploaded. Than modify your code to <a class="fancybox" title="<?php the_title(); ?>" href="???????"><?php artwork-thumbnail-image()?></a>
October 6, 201016 yr ah you want full image as well. You will have to use a custom field as well and that insert custom field value in href="" tag because featured image function outputs code in img tag not in a simple link. Maybe some php guru can help here.
October 6, 201016 yr This code is common to enable WP Thumbnail support. Put this in your functions.php functions.php if(function_exists('add_theme_support')) { add_theme_support('post-thumbnails'); // This is the small version for a list of posts. add_image_size('small-thumb', 150, 150); // This is the medium version, style as you see fit. add_image_size('medium-thumb', 420, 9999); // This is the large version (arbitiary large version) for single and full view. add_image_size('full-thumb', 800, 9999); } index.php <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="post"> <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <a href="<?php the_permalink() ?>"><?php the_post_thumbnail('small-thumb') ?></a> <?php the_excerpt(''); ?> <a class="more" href="<?php the_permalink() ?>">Read more . . .</a> </div> <!-- END post --> <?php endwhile; else: ?> <p>There have been no posts created yet.</p> <?php endif; ?> single.php <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="post"> <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <a href="<?php the_post_thumbnail('full-thumb') ?" class="fancybox"><?php the_post_thumbnail('medium-thumb') ?></a> <?php the_content() ?> <a class="more" href="<?php the_permalink() ?>">Read more . . .</a> </div> <!-- END post --> <?php endwhile; else: ?> <p>There have been no posts created yet.</p> <?php endif; ?> I assume for a fancy box to work you apply a class of "fancybox". So give the anchor the path to the large and the image the path to the small or any other combo. You can create as many versions as post thumb passing the parameter of a name. Then call the function with the desired size / name from any theme file as desired.
October 12, 201016 yr why don't you simply use this plugin ? http://www.pedrolamas.com/projectos/jquery-lightbox-en/
Create an account or sign in to comment