WordPress.org

Forums

Spun
way to make no image to be shown in the circle, just the title of the post (11 posts)

  1. WeasePR
    Member
    Posted 1 year ago #

    On using spun theme if I put an image in a post and no featured image, is there a way to make no image to be shown in the circle, just the title of the post?

  2. WeasePR
    Member
    Posted 1 year ago #

    LOL sorry scuse the bad grammar at beginning of that sentence!

  3. Caroline Moore
    Member
    Theme Author

    Posted 1 year ago #

  4. WeasePR
    Member
    Posted 1 year ago #

    Just found this! thanks Caroline!

  5. WeasePR
    Member
    Posted 1 year ago #

    Hi Caroline - Andrew's post was about having the text and image so no luck there.

    I have tried this:
    (in child theme)
    copy content-home.php from theme and pasted it into your Child Theme directory.

    open the content-home.php file (from your child theme)

    found this part at the top "/*
    * Get the post thumbnail; if one does not exist, try to get the first attached image.
    * If no images exist, let's print the post title instead.
    */"

    and replaced with
    "/*
    * Get the post thumbnail; if one does not exist, let's print the post title instead.
    */"

    This only works on the 1st circle but not any of the rest! Any ideas?

  6. WeasePR
    Member
    Posted 1 year ago #

    Hi did anyone see this? Just giving it a bump up the list.

    I'm still fiddling around with my site design and want to be able to use images in my posts but NOT have the images show in the circles.

    Any ideas?

  7. MerlijnK
    Member
    Posted 1 year ago #

    Hey,

    I'm a newby here, but I just tried some stuff. I have no idear if any unwishfull side-effect will appear. But it worked for me.
    I deleted:

    /*
    * Get the post thumbnail; if one does not exist, try to get the first attached image.
    * If no images exist, let's print the post title instead.
    */
    
    global $post;
    $postclass = '';
    
    if ( '' != get_the_post_thumbnail() ) {
    	$thumb = get_the_post_thumbnail( $post->ID, 'post-thumbnail', array( 'title' => esc_attr( get_the_title() ) ) );
    }
    else
    
    In the next part i changed the word 'image' for title
    
    $args = array(
    				'post_type' => 'attachment',
    				'numberposts' => 1,
    				'post_status' => null,
    				'post_mime_type' => 'image',
    				'post_parent' => $post->ID,
    			);
    
    to 
    
    $args = array(
    				'post_type' => 'attachment',
    				'numberposts' => 1,
    				'post_status' => null,
    				'post_mime_type' => 'title',
    				'post_parent' => $post->ID,
    			);
    
    So content home php code in total reads: 
    
    <?php
    /**
     * @package Spun
     * @since Spun 1.0
     */
    
    {
    	$args = array(
    				'post_type' => 'attachment',
    				'numberposts' => 1,
    				'post_mime_type' => 'title',
    				'post_status' => null,
    				'post_parent' => $post->ID,
    			);
    
    	$first_attachment = get_children( $args );
    
    	if ( $first_attachment ) {
    		foreach ( $first_attachment as $attachment ) {$thumb = wp_get_attachment_image( $attachment->ID, 'post-thumbnail', false, array( 'title' => esc_attr( get_the_title() ) ) );
    		}
    	}
    	else {
    
    		$thumb = '<span class="no-thumbnail">' . get_the_title() . '</span>';
    		$postclass = 'no-thumbnail';
    	}
    }
    ?>
    
    <article id="post-<?php the_ID(); ?>" <?php post_class( $postclass ); ?>>
    	<a>" title="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php echo $thumb; ?></a>
    </article><!-- #post-<?php the_ID(); ?> -->
  8. MerlijnK
    Member
    Posted 1 year ago #

    Let me know if this helpfull

  9. tpr007
    Member
    Posted 1 year ago #

  10. jdmedia
    Member
    Posted 1 year ago #

    I say keep it simple! Instead of getting into the code, simply create an .jpg image 300px by 300px (or something like that) of the title of the post. I use GIMP for this but you could use Paint or anything else which enables you to make jpg's quickly and easily. Upload this image to Media making sure to give it a meaningful file name/useful alt text. Then set it as a featured image for the post. Job done. This was my solution.

    The result is that you get the text you want in the circle on the front page. You can then insert your images as desired into the post and they will not show up in the circles (featured image comes first, so if that is set, that's what you'll see). And you have the added benefit of being able to use extra fonts/colours which would be complicated with CSS.

    Someone will probably come along and say you should never hide text in images but I say that's rubbish. Just do it and make sure you give image files meaningful names and alt text.

  11. Andrew
    Forum moderator & snail smusher
    Posted 1 year ago #

    Can you resize and restyle text in images? You can change settings in browsers to display text at a certain size and style. This can be to increase readability. By using text in images that freedom is taken away.

    From a technical perspective you really should avoid loading unnecessary images as each image is a HTTP request http://developer.yahoo.com/performance/rules.html

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags

No tags yet.