WordPress.org

Ready to get started?Download WordPress

Forums

Oxygen
Removing grey image placeholder if post has no image (9 posts)

  1. amanasufi
    Member
    Posted 1 year ago #

    I looked through all the support forum, but I couldn't find a way to make posts show up in the archives, search results, and static front page 'recent articles' tab without a big grey box if there is no image. You can see what I'm talking about at http://albayanmag.org/?s=suburb&submit=Search

    I'm not sure what to edit so that instead of a grey box appearing where a picture would normally be, there would be nothing and there wouldn't be an empty blank space either.

  2. esmi
    Forum Moderator
    Posted 1 year ago #

  3. amanasufi
    Member
    Posted 1 year ago #

    Thanks esmi, but Oxygen isn't from organicthemes, it's from alien-wp I think.

  4. esmi
    Forum Moderator
    Posted 1 year ago #

    Sorry - grabbed the wrong link. It should have been http://devpress.com/forums/

  5. Mark
    Member
    Posted 1 year ago #

    In several of the Oxygen template files (search.php, archive.php, frontpage.php) you'll find a call to get_the_image, as follows:

    <?php if ( current_theme_supports( 'get-the-image' ) ) {
    
    								get_the_image( array( 'meta_key' => 'Thumbnail', 'size' => 'archive-thumbnail', 'image_class' => 'featured', 'attachment' => false, 'width' => 470, 'height' => 140, 'default_image' => get_template_directory_uri() . '/images/archive-thumbnail-placeholder.gif' ) );							
    
    							} ?>

    What generates the grey placeholder is the last setting in that function call: 'default_image' => get_template_directory_uri() . '/images/archive-thumbnail-placeholder.gif'

    If you remove that or change it to 'default_image' => FALSE, the placeholder image will not be shown.

    So what you want to have is this:

    <?php if ( current_theme_supports( 'get-the-image' ) ) {
    
    								get_the_image( array( 'meta_key' => 'Thumbnail', 'size' => 'archive-thumbnail', 'image_class' => 'featured', 'width' => 470, 'height' => 140, 'default_image' => FALSE ) );							
    
    							} ?>

    To apply these changes, do not fiddle with core files, but create a child theme, place copies of all the theme files you want to change in that child theme, and make the changes there.

  6. amanasufi
    Member
    Posted 1 year ago #

    Thanks. I tried something like that before by replacing the default image with a small transparent png, but your way is much cleaner. I've been having trouble hiding the blue read-article and article category labels that now are overlayed on top of the post text since the articles are missing. Do you know of a way to hide the read-article and category labels only for the posts with no image, but keep them for posts with images?

    Or alternatively, can I anchor the read-more button at the same height as the share this button under the text of each article in the archives and search page? If the text is too short the read-article button appears over the like button which is distracting. For example, the post 'Forum' on http://albayanmag.org/?s=ome&submit=Search .

  7. annipoppen
    Member
    Posted 6 months ago #

    I'm working with a client who can't afford to pay for customizing or hosting... is there a way to get rid of that gray box without going into code? They have hundreds of old posts that a theme shouldn't require a featured image.

    On one of these forums I saw the author say he'd fix this in the next update, but that was a year ago. Seems sad for such a great theme to go to waste over one line of code.

    Thanks!

  8. sebastianbeckers
    Member
    Posted 6 months ago #

    I have also looked into that, and intuitively I would say not without changing Code. If anyone else knows better I would also appreciate to know about it.

    But creating a child theme and adding the code mentioned above should not be a big deal...

    Or you have to select a default image, lets say the company logo, and add it to every post without an own featured image. Time consuming but easy to do and no coding required and easy to use in future as well.

    But if the client can not afford to pay he somehow should understand that he can't have everything :-)

  9. bagra
    Member
    Posted 5 months ago #

    Hay Mark,

    Its working perfect.

    But how to remove "Read Article"...

    Please help...

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic