Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Featured Image

  • 18-04-2012 9:17pm
    #1
    Registered Users, Registered Users 2 Posts: 289 ✭✭


    Hi all,

    I am new to Wordpress and am currently experimenting with a wordpress blog to try and learn the ins and outs of it. I am trying to develop the homepage at present to display an image with each post, using the featured image option, as this is an easy way of adding a photo when writing a post. However, my theme currently has a standardised thumbnail image that it puts beside each post, which I have found in the code so thats straight forward enough.

    Also, I was wondering that when I find out what this code is and get it working, is it possible to set what size the image is to display at, preventing the user from having to re-size the image before they upload it and set it as the featured image?

    Any help with this would be very much appreciated.

    Rgds

    Paul


Comments

  • Registered Users, Registered Users 2 Posts: 241 ✭✭fcrossen


    This:
    http://markjaquith.wordpress.com/2009/12/23/new-in-wordpress-2-9-post-thumbnail-images/
    should see you right.

    However consider using a child theme rather than hacking a theme.


  • Posts: 0 [Deleted User]


    The above link should get you sorted in most cases. I've seen some third-party themes bypass the internal post_thumbnails feature and use add-on scripts like tim thumb.


  • Registered Users, Registered Users 2 Posts: 289 ✭✭paulgrogan.eu


    fcrossen wrote: »
    This:
    http://markjaquith.wordpress.com/2009/12/23/new-in-wordpress-2-9-post-thumbnail-images/
    should see you right.

    However consider using a child theme rather than hacking a theme.

    Thanks a million for coming back to me with that. I am using the Revolution Church theme, but I am using the free version for now and what I am trying to do is possible as I've seen it done with this team, but uncertain how.

    In reference to the child theme, could you explain what you mean by this?

    Many thanks

    Paul


  • Registered Users, Registered Users 2 Posts: 241 ✭✭fcrossen


    I am using the Revolution Church theme, but I am using the free version for now and what I am trying to do is possible as I've seen it done with this team, but uncertain how.

    It's all possible, however older themes will not have the newer Wordpress features (like featured images). If you are happy with a bit of PHP coding, then it isn't a problem.
    In reference to the child theme, could you explain what you mean by this?

    A child theme inherits from the parent, but will not be overwritten if/when the parent theme is updated. See http://codex.wordpress.org/Child_Themes.


  • Registered Users, Registered Users 2 Posts: 289 ✭✭paulgrogan.eu


    Hi all,

    Thank for your help up to now. I have now successfully managed to get the featured images working with my theme, and have also managed to get them to display in 2 diffenent sizes in 2 locations on the home page.

    However, when a visitor clicks on an article, I wanted to display the uncropped image at the top of the article, so basically I need to resize it to a third different size.

    My functions code currently looks like this:

    [PHP]if (function_exists('add_theme_support')) {
    add_theme_support('post-thumbnails');
    set_post_thumbnail_size(580, 200, true); //Sets the default image to 50x50px and crops it
    add_image_size('post-hero', 280, 100, true); //Adds the large style images
    add_image_size('post-large', 580, true); //Adds the large style images
    }[/PHP]

    However, when I set the articles to post with thumbnail or post-hero, there is no issue, but the post-large does not work.

    Any feedback on how I could get this to work would be very much appreciated.

    Rgds

    Paul.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 241 ✭✭fcrossen


    You'll kick yourself... you are missing a parameter:
    [PHP]add_image_size('post-large', 580, true); //Adds the large style images[/PHP]

    Keep an eye on your error logs (I always 'tail -f' in a terminal so I can spot this kind of stuff quickly).


  • Registered Users, Registered Users 2 Posts: 289 ✭✭paulgrogan.eu


    fcrossen wrote: »
    You'll kick yourself... you are missing a parameter:
    [PHP]add_image_size('post-large', 580, true); //Adds the large style images[/PHP]Keep an eye on your error logs (I always 'tail -f' in a terminal so I can spot this kind of stuff quickly).

    Hi,

    When you say a parameter, I assume you mean a size setting? IE: I only have 580?

    I had left this out on purpose as I didnt want the height cropped, I was hoping it would simple set the height based on the width setting?

    Rgds

    Paul.


  • Registered Users, Registered Users 2 Posts: 241 ✭✭fcrossen


    I had left this out on purpose as I didnt want the height cropped, I was hoping it would simple set the height based on the width setting?
    No, the third parameter should be the width. You have passed TRUE:
    From http://codex.wordpress.org/Function_Reference/add_image_size:
    [PHP]add_image_size( $name, $width, $height, $crop )[/PHP]

    Try
    [PHP]add_image_size( 'post-large', 580, 9999, FALSE )[/PHP]
    The 9999 pixel value for $height effectively makes it unlimited. You must pass the third parameter so you can pass $crop = FALSE as the 4th parameter.


  • Registered Users, Registered Users 2 Posts: 289 ✭✭paulgrogan.eu


    Hi,

    Perfect. That seems to be working a treat! Many thanks!

    Now, next request, if I want to put some caption text under one of the featured images, how should I go about it?

    Many thanks

    Paul


  • Registered Users, Registered Users 2 Posts: 241 ✭✭fcrossen


    Now, next request, if I want to put some caption text under one of the featured images, how should I go about it?

    There are various ways to do this but all require a bit of jiggery-pokery.

    Look at the source for the function:
    [PHP]get_the_post_thumbnail( $post_id = NULL, $size = 'post-thumbnail', $attr = '' )[/PHP] (http://core.trac.wordpress.org/browser/tags/3.3.2/wp-includes/post-thumbnail-template.php)

    You can create a function based on that code or you should be able to get the result you want using one of the action hooks or filters ('end_fetch_post_thumbnail_html' or 'post_thumbnail_html').

    Once you have the image id you can use get_posts() to get the image metedata. This should help - http://wordpress.org/support/topic/display-caption-with-the_post_thumbnail#post-1737293 (last post).


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 289 ✭✭paulgrogan.eu


    Is it possible to do caption text with an extra field plugin?


  • Registered Users, Registered Users 2 Posts: 241 ✭✭fcrossen


    Is it possible to do caption text with an extra field plugin?
    It may well be, but by the time you trawl through the lists and pick a decent one you'd probably have the job done yourself.
    Just because it's a WP hosted plugin doesn't mean it is any good.


  • Registered Users, Registered Users 2 Posts: 289 ✭✭paulgrogan.eu


    fcrossen wrote: »
    It may well be, but by the time you trawl through the lists and pick a decent one you'd probably have the job done yourself.
    Just because it's a WP hosted plugin doesn't mean it is any good.

    Oh really? Like all I want to do is put in some simple description text and a copyright note, and I feel it would be easier for the end user to type it in there, rather than trying to do it in the image module. There may be a number of people using this site with varying levels of IT expertise.

    I thought that it may be possible to code that extra field into the code of the page?

    Rgds

    Paul


  • Registered Users, Registered Users 2 Posts: 6,571 ✭✭✭daymobrew


    Oh really? Like all I want to do is put in some simple description text and a copyright note, and I feel it would be easier for the end user to type it in there, rather than trying to do it in the image module.
    If the description text is the same as the post title then it is easy. If not, maybe you could use a custom field for the post.
    Can you provide a screenshot of what you have and annotate it with what you are looking for?

    When you upload an image you give the picture a name - can you access that for a featured image?


  • Registered Users, Registered Users 2 Posts: 289 ✭✭paulgrogan.eu


    daymobrew wrote: »
    If the description text is the same as the post title then it is easy. If not, maybe you could use a custom field for the post.
    Can you provide a screenshot of what you have and annotate it with what you are looking for?

    When you upload an image you give the picture a name - can you access that for a featured image?

    Ok, I currently have a layout as follows:

    [TITLE]
    [FEATURED IMAGE - RESIZED AND CROPPED]
    [FULL-STORY]

    What I would like is the following:

    [TITLE]
    [FEATURED IMAGE - RESIZED AND CROPPED]
    [CUSTOM FIELD TO ENTER TEXT EG: THIS IS A PHOTO OF JOE BLOGGS TAKEN BY MARY BLOGGS]
    [FULL-STORY]

    My preference would be to install a custom field on the Add News page just below where you enter the body text allowing the user to simply type in the text as in the example above and hit post and then it all appears as above to the user.

    Many thanks for your assistance.

    Paul


  • Registered Users, Registered Users 2 Posts: 241 ✭✭fcrossen


    ...all I want to do is put in some simple description text and a copyright note, and I feel it would be easier for the end user to type it in there, rather than trying to do it in the image module.
    Do you mean the user types it directly into the post editor or as a field in the media uploader?
    You will need to code to retrieve the description, along with some tweaking of your template code (which I am guessing you have already done).
    As daymobrew says, you can also use the description field in the media uploader and retrieve it programmatically as I described earlier. Your users will need to upload the image anyway, so they'll need to know how to use the uploader.
    There may be a number of people using this site with varying levels of IT expertise.
    End user training...? :D
    I thought that it may be possible to code that extra field into the code of the page?
    I am not 100% sure what you mean by this, but I can't see any way of doing this without some custom programming. How's your PHP?
    In fairness though, it isn't a big job, and someone who knows what they are doing should be able to accomplish it for beer money (depending on how thirsty they are)!


  • Registered Users, Registered Users 2 Posts: 289 ✭✭paulgrogan.eu


    Hi all,

    Thanks to the posts above, I've managed to get the captions to show from within the media library page. However, they are showing beneath the featured image in every area, IE: Under the image on the home page where an exerpt is shown and the caption is shown, but I only want the caption shown on the page where you view the full news article?

    Also, how can I change the font size etc of the caption text from being different to the body?

    Many thanks!

    Paul


  • Registered Users, Registered Users 2 Posts: 241 ✭✭fcrossen


    Thanks to the posts above, I've managed to get the captions to show from within the media library page. However, they are showing beneath the featured image in every area, IE: Under the image on the home page where an exerpt is shown and the caption is shown, but I only want the caption shown on the page where you view the full news article?
    If you created a PHP function and hooked in then you want to only add your extra HTML to the image if on certain pages.
    One of the Wordpress conditional tags will help you.
    See is_archive() or one of the related functions.
    Also, how can I change the font size etc of the caption text from being different to the body?
    Some CSS in your theme (preferably in a child theme).


  • Registered Users, Registered Users 2 Posts: 6,571 ✭✭✭daymobrew


    fcrossen wrote: »
    If you created a PHP function and hooked in then you want to only add your extra HTML to the image if on certain pages.
    One of the Wordpress conditional tags will help you.
    See is_archive() or one of the related functions.
    is_single() is for single post pages.
    Or you can edit single.php for the same result.


  • Registered Users, Registered Users 2 Posts: 289 ✭✭paulgrogan.eu


    Ok, guys, next bit of help! Thanks so much for everything so far!

    The template I am using uses:

    [PHP]<?php bloginfo('rss_url'); ?>[/PHP]

    to obtain the News RSS feed.

    I want to configure this so it only selects news for the RSS feed from one particular category, but after spending hours googling and buried in code, I have been unable to make any headway with it.

    Any assistance would be very much appreciated.

    Rgds

    Paul


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 6,571 ✭✭✭daymobrew


    I want to configure this so it only selects news for the RSS feed from one particular category, but after spending hours googling and buried in code, I have been unable to make any headway with it.
    I searched for "wordpress rss single category" and found WordPress Feeds.

    It suggests one of the following:
    http://www.example.com/?cat=42&feed=rss2
    http://example.com/category/categoryname/feed


Advertisement