Viewing 13 replies - 1 through 13 (of 13 total)
  • HI,
    Do u want to display random images or the featured image of the page/post?

    Thread Starter KJGreen

    (@kjgreen)

    Menaka,

    Thank you. Either would be great. I don’t mind delegating a featured image per page. If that’s the case, I may want to create a global variable for an image that I don’t mind being the featured image for multiple pages.

    By random images, I assume you mean an array of images that I can create rather than a random scroll through of my wordpress media library. Just checking. ??

    Thanks again.
    Karli

    I have been trying to work out how to make a page display the featured image in exactly the same way that a single ‘standard’ post already displays it within the theme (1170 by 500 px image displayed full width above breadcrumb trail).

    I feel that there must be an action or filter that enables this for a post (but I don’t know where to find it) that could be adapted and pasted somewhere (in child theme functions.php?) but I need help finding and adapting it!

    I think that’s part of what KJGreen wants, so I thought that it would be OK to chip in to this addition. If I’m mistaken then I apologise and will retreat.

    Best wishes

    Ian

    Thread Starter KJGreen

    (@kjgreen)

    Thanks for chiming in, Ian. Yes, that’s exactly what I want. I didn’t realize that this was already a built-in feature for posts. Prefer the boxed layout above the title of a page, but I imagine that’s just one difference from the full-width. Any ideas?

    Thread Starter KJGreen

    (@kjgreen)

    Ended up just inserting an image directly at the top of the page with its own class in my child theme. Here’s my css…super simple. Would have been cool to have this functionality for pages.

    .pagebanner {
    width:100%;
    box-shadow: 10px 10px 5px #888888;
    margin-bottom:25px;
    }

    Karli, I’m still looking into how to place the featured image above the title, etc programmatically. It’s harder than I anticipated because I cannot manage to google an answer (or even clue) and I was unfamiliar with WordPress hooks, actions and so forth that are fundamental to the Customizr theme, I have discovered.

    I may not be successful, but will aim to report back here within a few days either way.

    Thanks for your css approach, which I may well fall back on!

    Ian

    Hi KJGreen,
    So, is your issue resolved?

    Thread Starter KJGreen

    (@kjgreen)

    Menaka,

    The issue is resolved with a patch. It would be great to have a built-in functionality for the featured images to pages, like featured images to the posts. I also tried to dive into the php backend like Ian and was unsuccessful.

    It may take me longer to find a ‘proper’ solution, if I ever do, than the fast-moving world of forums allow, but if I do then I’ll report back at some point. ??

    In the meantime I found an easy, but very kludgy, work-around that doesn’t require any programming or css knowledge (part of the reason I was looking into Customizr theme). It seems to have problems if you resize window – but is that really so frequent?

    If you make a Customizr slider with one image – the featured image – it i displays where we want. Resizing the window can break it, but it is, at least, easy!

    Ian

    PS The one-slide slider can be full width or not.

    @kjgreen,
    I shall flag it to developers as a possible feature. Can you mark the post as resolved?

    Thread Starter KJGreen

    (@kjgreen)

    Thank you for your help. Thank you too, Ian.

    For Karli, or anyone else viewing this thread hoping to address a similar problem:

    Here is my rather Frankenstein code (with sources) that displays full-width copies of the featured image for pages beneath the header, above the crumb trail:

    <?php
    // 2016-05 Include featured image (at Customizr standard 1150px by 500px) full width beneath header
    // 2016-05 adapted from https://presscustomizr.com/snippet/adding-block-content-header/
    // with some of https://www.ads-software.com/support/topic/featured-image-not-working-want-to-remove-help-from-admin-bar
    
    // we add the action with priority set to 5 => it will be displayed in first position (before the slider if any)
    add_action ('__after_header' , 'show_featured_image_after_header', 20);
    
    function show_featured_image_after_header(){
        if (! ( is_page() && has_post_thumbnail() ) )
            return;
        /*
         * set this to false to use the original image size
         * (note: it's resized according to its container width)
         * change this to true to use customizr thumbnail size
         * by default 270x250 px
         */
        $use_tc_thumb = false;
    
        /*
         * chose a wordpress thumbnail size:
         * 'thumbnail', 'medium', 'large', 'full'
         */
        $alternative = 'full'; 
    
        $thumb_size = ($use_tc_thumb) ? 'tc-thumb': $alternative;
        ?>
    		<div id="my-content-header">
    			<div class="row-fluid">
    				<div class="span12 text-center">
            <?php the_post_thumbnail($thumb_size); ?>
    				</div>
    			</div>
    		</div>
    	<?php
    }

    It almost certainly includes much redundant code, but it seems to work. The site I’m developing where this is used is unavailable publicly, at present. So sorry for no link.

    Best wishes

    Ian

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Add Image Before Content’ is closed to new replies.