• Hi,

    When I’ve previously built CMS I tend to have a field for the thumbnail to go in. I then position this thumb to the right in a <div> element, with the content on the left.

    However, I notice in WP when you make a ‘Post’, there’s no option to add an image, just one inside the post?

    Is there any plugin I can use to add 1 thumbnail/image to a news item, or is it possible to style the image added and position it to the right, keeping the content to the left?

    Many thanks for any suggestions.

Viewing 15 replies - 1 through 15 (of 15 total)
  • you can use custom fields for this.

    set up a new custom field called ‘thumbnail’ or ‘feature’ or whatever you want to call it, and set the value to the URL of your picture.

    check out this page for how to use that information:
    https://codex.www.ads-software.com/Using_Custom_Fields

    Thread Starter michaelmcguk

    (@michaelmcguk)

    Brilliant, it did the job ??

    Used a mix of this too: https://www.gate303.net/2007/09/25/wordpress-custom-fields-guide/

    fruit please! ??

    Thread Starter michaelmcguk

    (@michaelmcguk)

    Just wondering, will I always have to type in HTML for the image tag, or is there a way to ‘drop it’ into the custom field I’ve added?

    Thanks once more.

    well, I don’t know exactly where you’ve put your custom field stuffs… but…

    the way I would do it, is to stick it into your template, not into each post…

    so inside The_Loop™, just BEFORE your post title.. you could put:

    <div class=”MyLitteImage” style=”float:right;”>
    <img src=”<?php [custom field URL goes here] ?>”> alt=”” />
    </div>

    I say before, because that’ll make your image the same height as the title, but on the right.

    If you wanted it the same height as the content, then put that code in your template, right after the title, and before the content.

    That way, when you enter the custom field data in your post, it is extracted into the template in this location.

    no additional HTML required.

    Thread Starter michaelmcguk

    (@michaelmcguk)

    Aaaah ok.

    Basically right now I have it set up where I have to put HTML directly in e.g.

    <img src="images/calendar.jpg" alt="" />

    So instead, I should perhaps just enter the image url like you say.

    Again, apologies for being such a newb, but I’ve literally just started out with WP and am a sucker for asking on forums ??

    no worries ??

    really, there isn’t a lot of difference to me, between using custom fields for this, and putting an image in as the first line of each blog post.

    I’m inclined to think its easier to put it in your post, but… you asked.

    Thread Starter michaelmcguk

    (@michaelmcguk)

    Heheh you’re right, it’s much easier to have it in the post, but it just won’t work the way I’d like it to.

    I basically want all my text aligned to the left and image in the post to the right. Not sure how do-able it is though ??

    Don’t want any text-wrapping however on the image, that’s the hard part.

    ahhh hold on… can you mock up a picture of what you want? I’m having trouble picturing exactly what it should look like.

    if you don’t want it to wrap text, I think maybe you might have to use custom fields – either that, or be really tricky with absolute positioning using CSS, with an image inside the post.

    Mock it up… we’ll work it out.

    Thread Starter michaelmcguk

    (@michaelmcguk)

    Apologies for the late reply, lunch-time ??

    Idea

    ok, that was definitely clear enough.

    it’s all down to the css I reckon… lets just try to be creative with that first, and if you don’t like the results we can resort to custom fields.

    not having a link to your site, I’m going to guess that your css classes are named just like the default Kubrick theme (which is pretty common, cos everyone seems to mod that)

    you’ll need to squeeze your ‘entry’ class to make way for the image.

    lets say the image is 75 pixels wide.. your ‘entry’ class will need to have the following in it:

    margin-right: 85px;

    or if there are existing margins defined, incorporate your new margin thusly:

    margin: x 85px x x

    where the Xs are whatever other margins you have there.

    you also want the ‘entry’ class to allow for its contents to be positioned absolutely. You can do that by adding:

    position: relative;

    now you need to work out how wide your resulting text entry space is. add another line to .entry to put a border around it (border: 1px solid #ff0000;) once that’s in place, screen cap your page, and use your favourite picture editing proggie and find out how many pixels there are there, including the border.

    lets call that number $y

    now… if this will be the only image in your posts, you can make a new definition in your style sheet that goes something like this:

    .entry img {
       position: absolute;
       top: 0;
       left: $y+10;
    }

    don’t put the honking $+%$ shit in there, just add ten to the number you found earlier.

    make sense? – we’re trying to force the image outside the .entry class. this should work just fine, and avoid your custom field crapola.

    if this won’t be the only image in your post, then you’ll need to add another class like…

    .entry .feature {
       position: absolute;
       top: 0;
       left: $y+10;
    }

    then make sure your first line in each post is:

    <img class="feature" src="[url goes here]" alt="" />

    I think that should do it. If not… fruit!

    Thread Starter michaelmcguk

    (@michaelmcguk)

    Worked a treat Ivovic!

    Dead easy once you explained it.

    Thanks!

    Most welcome ??

    actually, technically speaking, I overstated the importance of it being the first line in the post. If you use the .feature class in your image tag, you can put it pretty much anywhere in the post, but not more than one in each, otherwise they’ll end up exactly on top of each other.

    Hi,

    I would like to put the image on a post that is made like “news’ style”, with the image on the left with the title and post on the right – the image is aligned with the title. You suggested to make use of the custom field but then you guys decided to go for the template.

    I would like some help of what value I should put in the custom field option? The key I am going to use is ‘image’ – but I am clueless of the value. The image size should be 200×200

    Any help is greatly appreciated.

    well, that’s the easy part…

    the value is the URL to the uploaded image (which you would have to upload by other means)… so that you can then use that value in an image tag, in your template.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘News page to have image? CSS issue…’ is closed to new replies.