WordPress.org

Ready to get started?Download WordPress

Forums

Default thumbnail in functions.php? (30 posts)

  1. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    OK, here's something I'm trying to figure out..... Is there a way to specify a default thumbnail in my functions.php file?

    Currently I have this (in functions.php):

    // THIS IS THUMBNAIL SUPPORT
    if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9
    	add_theme_support( 'post-thumbnails' );
    	set_post_thumbnail_size( 50, 50, true ); // Normal post thumbnails
    	add_image_size( 'single-post-thumbnail', 300, 999 ); // Permalink thumbnail size
             add_image_size( 'title-image', 50, 27 ); // Title mini photo
    }
    
    // THIS LINKS THE THUMBNAIL TO THE POST PERMALINK
    
    add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
    
    function my_post_image_html( $html, $post_id, $post_image_id ) {
    
    	$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
    
    	return $html;
    }

    to define my thumbnail, and to link it to the permalink

    now I use the thumbnail and it's various iterations throughout my theme. So atm, I use this to swap in a default image in one of the locations (index.php):

    <?php
    if ( has_post_thumbnail() ) {
         the_post_thumbnail('title-image', array('class' => 'titleImage', 'alt' => 'Title Icon'));
         } else {
         echo "<img src='" . get_bloginfo('template_directory') .
        "/images/defaultIcons/voodooTitleDefault.png' alt='Default Title Icon' title='Default Title Icon' class='titleImage' />"; }
    ?>

    which works fine enough. But I have to include that buncha code in each of 4 or 5 locations to get a default image. Plus I use the thumbnail on my main (non-WP) page...it's getting to be a pain to use all that. Plus the if/else I have above doesn't include the permalink link.

    So.....is there a way for me to specify the default thumbnail one time in functions.php, so all of my thumbnail uses throughout my theme and beyond will have the default available if I don't specifiy one?

    Thanks much in advance!

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    yup....I'm definitely in over my head on this one.... And...I think I just found the end of google.

    I've tried a lot of cut & paste of various php stuff.....thing is I'm just not so bright at this stuff.

    I found this:
    http://wordpress.org/extend/plugins/default-post-thumbnails

    But it's not working....as I get a default thumbnail just dropped into my posts....not at my specified sizes, with my classes, in the multiple places I have set up, etc

  3. Mark / t31os
    Moderator
    Posted 4 years ago #

    add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
    
    function my_post_image_html( $html, $post_id, $post_image_id ) {
    
    	$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
    
    	return $html;
    }

    Looking at your filter above, it would appear(i'm not certain) to me that when no image is returned, you'll actually still be getting a link output(the link in your filter will still output even when $html is set to an empty to string).

    You could do a very simple condition in the filter..

    add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
    
    function my_post_image_html( $html, $post_id, $post_image_id ) {
    	if( '' == $html )
    		$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '"><img src="defaultimageblahblah" /></a>';
    	else
    		$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
    	return $html;
    }

    I could be wrong about the output though, i'm not sure..
    [1] - http://core.trac.wordpress.org/browser/trunk/wp-includes/post-thumbnail-template.php

    I'm assuming at this point that when no thumbnail exists, get_the_post_thumbnail[1](scroll down to the bottom - last function) still returns the $html value set as an empty string, when no thumbnail exists. Of course my assumption could be wrong.

    Can you confirm?

  4. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    hmmm....no dice it seems. I messed up the url to my image the first time, which totally blew my site up (no css, no admin)

    So I tweaked it....which let me back in....but with a correct url, I get nothing happening differently

    Can you confirm?

    I'm not sure what to confirm? Sorry..... I'm at the edge of my knowledge here. I do know that the thumbnails put into my index.php by the_post_thumbnail has the permalink assigned to them. The alternate 'default' icon assigned by the if/else statement in index.php does not have any permalink attached (as expected). Same hold true with the new code dropped into functions.php, and no additional images were spit out anywhere in my page and nothing appeared in my source to make me think anything was going on differently.

    Thanks so far!!

  5. Mark / t31os
    Moderator
    Posted 4 years ago #

    Ok looks like i'll have to test the code... ;)

    Will reply once i've had a chance to test.. :)

  6. Mark / t31os
    Moderator
    Posted 4 years ago #

    Ok, turns out that the filter change i suggested before does work, but you'll need to make a change to how you're calling the post thumbnail..

    Remove this condition..

    if ( has_post_thumbnail() ) {

    Whenever a post doesn't have a post thumbnail, the function the_post_thumbnail will return an empty string, when it returns an empty string, you can catch it with the filter and return something else. By using that condition, the empty string case can't be met.

    So if you take this code.

    add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
    
    function my_post_image_html( $html, $post_id, $post_image_id ) {
    	if( '' == $html )
    		$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '"><img src="defaultimageblahblah" /></a>';
    	else
    		$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
    	return $html;
    }

    And remove the condition around the_post_thumbnail it will work.. (adjust the example image code of course).

    NOTE: There's nothing wrong with *not checking* if there's a thumbnail with has_post_thumbnail, because the_post_thumbnail returns empty on fail(so you won't get any errors or anything like that).

    Essentially all this means is, that instead of doing this everywhere...

    <?php if ( has_post_thumbnail() ) the_post_thumbnail(); // I'm only shown when i'm not empty ?>

    You now just do..

    <?php the_post_thumbnail(); // I'm an empty string when i fail ?>

    Which then allows you to filter the function and return a default image when it's empty... :)

  7. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    OK, we gettin somewhere! Thanks for sticking around so far!! So now we have the default image getting dropped in wherever I use the_post_thumbnail.....but......they all come up the same size, and totally bypass any further modification. Which I guess means there's something going on here that's still above my paygrade....

    I'm guessing it's because we are appending the html output after the thumbnail sizes are set....and dropping in an image url...so it's just affecting the actual url output and has nothing to do with the original sizes I set up?

    So here's the total code I have in functions.php....

    // THIS IS THUMBNAIL SUPPORT
    
    	add_theme_support( 'post-thumbnails' );
    	set_post_thumbnail_size( 50, 50, true ); // Normal post thumbnails
    	add_image_size( 'single-post-thumbnail', 300, 999 ); // Permalink thumbnail size
            add_image_size( 'title-image', 50, 27 ); // Title mini photo
    
    // THIS LINKS THE THUMBNAIL TO THE POST PERMALINK AND DROPS IN A DEFAULT IMAGE
    
    add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
    
    function my_post_image_html( $html, $post_id, $post_image_id ) {
    	if( '' == $html )
    		$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '"><img src="' . get_bloginfo('template_directory') . '/images/voodooplate.png" /></a>';
    	else
    		$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
    	return $html;
    }

    And I have 3 iterations of the_post_thumbnail in theme like so:

    <?php the_post_thumbnail('title-image', array('class' => 'titleImage', 'alt' => 'Title Icon')); ?>
    <?php the_post_thumbnail(array( 75,75,true ), array('class' => 'postImage', 'alt' => 'Post Thumbnail')); ?>
    <?php the_post_thumbnail('single-post-thumbnail', array('class' => 'pageImage', 'alt' => 'Full Page Image')); ?>

    so now....the multiple image sizes, the classes being appended in, etc, are ignored by the default. The sizes and classes of course are important for the layout. Is there a way to get the default thumbnail to play nice?

    Again, thanks a lot.... I'm quickly learning

  8. Mark / t31os
    Moderator
    Posted 4 years ago #

    Seems to be a bug of some kind, if i echo the $size directly in wp-includes/post-thumbnail-template.php it's there as expected, yet if i add the size into the filter, it's unable to see the size.

    The size should be available to the filter, here's the filter hook for reference.

    return apply_filters( 'post_thumbnail_html', $html, $post_id, $post_thumbnail_id, $size, $attr );

    You see size there, and it's fed a valid value inside the the_post_thumbnail function, yet it seems to be empty whenever i try to print it out(or do whatver with it) inside a filter.

    For ref: (opening line of function i'm using)

    function my_post_image_html( $html, $post_id, $post_thumbnail_id, $size, $attr ) {

    The problem can easily be confirmed by doing the following inside the filter function.

    print '<pre>';print_r( get_defined_vars() );print '</pre>';

    This is what i see.

    Array
    (
        [html] => image-code-is-shown-here
        [post_id] => 12
        [post_thumbnail_id] => 15
    )

    Values are examples.

    When what i'm expecting to see is..

    Array
    (
        [html] => image-code-is-shown-here
        [post_id] => 12
        [post_thumbnail_id] => 15
        [size] => the-size-value
        [attr] => any-attrs-given
    )

    Again values are examples.

    I'm not sure what i can suggest, the size never seems to be there, whether returning the default image or an actual post thumbnail, it's as if it vanishes somewhere along the way, when really it should be there (unless there's a mistake in my understanding of the filter hook - anyone is welcome to correct me).

  9. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    oooh. That's kind of a bummer! I was wondering where the extra 'stuff' was going....

    Thanks for taking the time on this one! It'd definitely be cool if the values didn't run away......saves a lot of time/code on implementing default thumbnails in multiple areas of a theme....especially when adding in classes, permalink links, etc.....

    I mean, its not so hard to set up using 4 or 5 different images as defaults....presized and everything, I just liked this idea much more!

    Anyway, thanks much for trying/testing!

  10. Mark / t31os
    Moderator
    Posted 4 years ago #

    It could be that i'm misunderstanding the filter hook available though, so it may simply be that size isn't available as i would have expected.

    It would be a little strange though, that two variables are passed to the hook if they're not intended to be available, again i might just misunderstand the usage.

  11. Mark / t31os
    Moderator
    Posted 4 years ago #

    Oh god, i'm such a fool, i've just spotted my silly error, it's here.

    add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );

    The last parameter is how many args/vars/parameters your filter will accept.. (there's 5 available on this particular hook).

    add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 5 );

    And voila $size is now available to the function... :)
    So you can do what you want inside the filter based on what's in that var now... :)

    Setting to 4 or 5 will allow you to access $size inside the filter.

  12. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    :D

    Ya know....I copied and pasted that bit.....and forgot to ever really figure out what the numbers were for

    Thank you so much! I'm gonna play a bit and report back!

  13. Mark / t31os
    Moderator
    Posted 4 years ago #

    First number is the priority and second is the supported args.

    The priority isn't necessarily always important, but can be useful when you're interacting with plugins or other functions that also run filters on the same function (you may want one to have precedence over the other for example).

    Just happy we found the problem... :)

  14. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    OK...sooooo (sorry to be needy!)

    how to use $size?

    I've just cruised the codex....looking at any sample code for attachments and whatnot (nothing is detailed enough for me to glean usage)....I'm just not following how to use the $size here:

    function my_post_image_html( $html, $post_id, $post_image_id, $size, $attr ) {
    	if( '' == $html )
    		$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '"><img src="' . get_bloginfo('template_directory') . '/images/voodooplate.png" /></a>';

    Guess I'm really kinda out of my element here. Like does $size specifiy what size image to use based on the settings I have further up in functions.php (the set_post_thumbnail_size, add_image_size stuff)?

    Also, I just noticed, in the filter you reference $post_thumbnail_id and I reference $post_image_id Is that an issue?

  15. Mark / t31os
    Moderator
    Posted 4 years ago #

    As far as i can see size contains the name you declared in the call to the post thumbnail, ie. title-image, single-post-thumbnail and so on...

    It does not however contain the width and height values. If you want them, i've found a way to get them... ;)

    Inside your filter..

    // ignore - forum first line indent bug fix
    	global $_wp_additional_image_sizes;
    
    	if( isset( $_wp_additional_image_sizes[$size] ) ) {
    		$width = $_wp_additional_image_sizes[$size]['width'];
    		$height = $_wp_additional_image_sizes[$size]['height'];
    	}

    And now $width and $height have the values that apply to the given size being called..

  16. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    I guess I'm not sure how to actually use the $size.....

    where do I plop it into the function to get the image to use the size?

    like it's in here..
    function my_post_image_html( $html, $post_id, $post_image_id, $size, $attr ) {

    but it goes somewhere else to actually apply size/declared name to the image?

    (btw, that height and width thing is nice....I'm studying that....)

  17. Mark / t31os
    Moderator
    Posted 4 years ago #

    $size simply contains the name of the registered image size you're calling, ie. single-post-thumbnail if that were what you were calling..

    To get the dimensions that apply to the that registered size you'd use something like i've posted above... then do as you choose with them..

    For images that aren't the default, dimensions are already applied, you only need apply sizes when outputting the default image, ie. when if( '' == $html ) is true..

    So to broaden the example.. based on your code posted further up

    add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 5 );
    
    function my_post_image_html( $html, $post_id, $post_thumbnail_id, $size, $attr ) {
    	if( '' == $html ) {
    		global $_wp_additional_image_sizes;
    		$dimensions = '';
    		if( isset( $_wp_additional_image_sizes[$size] ) ) {
    			$width = $_wp_additional_image_sizes[$size]['width'];
    			$height = $_wp_additional_image_sizes[$size]['height'];
    			$dimensions = 'width="'.$width.'" height="'.$height.'" ';
    		}
    		$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '"><img '.$dimensions.'src="' . get_bloginfo('template_directory') . '/images/voodooplate.png" /></a>';
    	} else {
    		$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
    	}
    	return $html;
    }

    Hope that helps... :)

  18. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    yup, it definitely helps me out a lot! Gives me something to work with, and code to peruse. The more i see, the more I can piece my own things together

  19. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    I'm sure I'm getting to be a pain.....but I'm diggin the progress we are making. I see what we are doing here, and I'm dissecting the code as we speak to understand it even better.....but here's some of the issues I'm running across to keep this from being perfect for me....

    We are pulling in the size attributes of the various registered image sizes.... and applying to the url..... er...html output

    So, it's gotten us pretty far down the road, the images indeed resize....

    But since the actual registered image name (title-image, etc) isn't applied to the default image.....a bunch of stuff still gets left out.

    On the image end of things, we get the size, but not the crop method.....so the images get distorted....but using the actual post_thumbnail they look good as cropping method is set....I guess?

    And then, on the actual posting side the default image, since it's not assigned the actual name, it bypassed my various
    <?php the_post_thumbnail('title-image', array('class' => 'titleImage', 'alt' => 'Title Icon')); ?>

    codes for displaying the images.... so we don't get the classes (so the css intended doesn't work)

    I know I'm taking up a lot of your time.....just trying to see if this all is possible? It'd great if the default image just knew what it was supposed to be named in each instance and behaved!!!

    I appreciate all your help thus far ...even if I don't get this down, I'm learning a fair bit here

  20. Mark / t31os
    Moderator
    Posted 4 years ago #

    Just fixing a laptop for a family member at the moment, i'll take a closer look once i can give the code more attention.

    I think know what you're saying, but all the data we need(i think) is in the $attr variable that is also being passed into the filter, ie. there's an array key called crop which is set to 1, when the item is to be cropped.. and likewise regarding the class..

    Bear with me a little while and i'll be able to bring my attention back to the code, right now i have a laptop infront of me that needs my attention (shouldn't be long though hopefully).

  21. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    it's more than cool, take your time. Like I said, much appreciate the attention you give this. (I've got a friends laptop to re-re-repair this week myself)

    Looking at stuff....I think if I get the crop method in there so I just get all the images looking proper, I may be able to just add some specificer (its a word!) redundant css to handle these various default images being inserted...

    unless of course we can have it pick up the classes, or some other cool trick to assign class by size or something!

    Anyway, thanks much!

  22. Mark / t31os
    Moderator
    Posted 4 years ago #

    Ok, been looking at this, and as i showed before, width and height would need to pulled from the image sizes array.. (example above should illustrate that easily enough).

    Class and alt text would be in your the_post_thumbnail call, so they'll be in the $attr variable.

    So all you need do is check what's in $atrr, and do what you want with it from there.

    In regard to cropping, whether an image is cropped i think may be related to whether you register that image size with cropping, it's the fourth paramater(defaults to false), although i'm not sure if that's strictly true.

    So here for example, when you're doing this..

    add_image_size( 'single-post-thumbnail', 300, 999 );

    You'd need to set that to..

    add_image_size( 'single-post-thumbnail', 300, 999, true );

    Once cropping is enabled, the array that stores the registered image sizes(as shown earlier), $_wp_additional_image_sizes will set the crop array item to 1(true)..

    Exactly what it means by setting crop to true is beyond me, the images appear the same on my install whether the registered image size has crop set to true or not(although maybe i need to upload a fresh image, i set after uploading).. , although in honesty i've not used these functions up until helping you out, apart from briefly for testing.. so i'm not sure on exact usage of the functions or how to utilise these new features properly.

    So for getting, width, height and crop values/settings look in the $_wp_additional_image_sizes array for that image size(it's array of every registered size), for attribute settings (ie. those you pass into the function), you'll find them in the $attr variable passed into the filter.

    Sorry if the above seems a little generic/general, i havn't used these functions at all apart from the odd piece of testing code here and there, and i can't personally quite grasp how to use them in the post editor(the whole image editting tool doesn't make much sense it how it works with the existing image features, i couldn't figure out how to make any kind of cropping work as one example).

    As far as i can tell though, you have all the values and attributes you need between the attr var and the image size array, to do any number of things with your default image, but let me know if there's anything else i can do to help further... ;)

  23. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    I'll be playing around for a while now..... you've given me a fair bit here to work with/learn from! thanks much!!!!!

  24. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    Guess I don't understand the crop thing either...

    when I assign a thumbnail using the interface in the post editor, the hard crop method (true) keeps the pic from stretching and just crops it.....like I want.

    I can see the crop => 1 in the array for each size, but it doesn'rt affect the default image. So...it works for assigned images, but not the default image. Guess the images need to be assigned through the editor to get the crop done properly?

    Meh....on to the class/alt stuff. I see them in the attr array, I just gotta compare the code you've already given me to figure out how to use the array to pass the class/alt into the pic url.

  25. Mark / t31os
    Moderator
    Posted 4 years ago #

    Ok but what actually happens to an image to make it crop so to speak? If you compare output source code between a cropped and non-cropped image, how do they differ, i imagine when it's cropped it's just simply output differently, if i can see the difference(s) in code form i can help you write that into your filter, as like i said, i quite couldn't figure out the cropping thing myself.

    If you want to post source code and highlight what should be what, etc... i'm sure i help adjust the filter... :)

    I must admit, i can't say i find these new image features tie in very well with the existing media functionality, if anything it makes the whole image media usage more confusing(imho). I really would welcome some extra input at this point from someone(anyone), who knows more about the usage.. (or that can provide some clear examples of how to use them correctly).

  26. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    Howdy! I messed around for a couple hours on trying to place the alt and class stuff.....never quite got it....but anyway

    <a href="http://www.rvoodoo.com/2010/04/planning-for-the-annual-voodoo-empire-backyard-bash/" title="Planning for The Annual Voodoo Empire Backyard Bash!"><img width="50" height="27" src="http://www.rvoodoo.com/empire/wp-content/themes/voodooempire3/images/voodooplate.png" /></a>

    Is the output of an image generated using the code we've worked on

    <a href="http://www.rvoodoo.com/2010/04/mix-of-the-moment-james-zabiela-2/" title="Mix of the Moment-James Zabiela"><img width="21" height="27" src="http://www.rvoodoo.com/empire/wp-content/uploads/2010/04/jameszabiela-21x27.jpg" class="titleImage wp-post-image" alt="Title Icon" title="jameszabiela" /></a>

    Is what we get from using a thumbnail inserted through the media screen
    it seems to append on the -21x27 to the end of the img url, and I get my class and alt on there.....

    you can check out the actual site if you want....I'm running the modified version now. rvoodoo.com

    its obvious which posts are using inserted thumbnails vs. default thumbnails

  27. Mark / t31os
    Moderator
    Posted 4 years ago #

    Ok so it looks like when you crop an image a new one is created with the new dimensions appended onto the end of the new file name.

    I'm not sure we could really do the same for the default image, since you'd have to create a cropped matching version for every cropped image you create (would be alot of work i imagine)...

    Here's what i'm thinking though, instead of cropping the default image, why not use an element that displays the default image as a background(find the closest size first), position the background appropriately, and resize that element based on the cropping size(image dimensions). That way you'd be cropping the element(in a manner of speaking) as appose to cropping the image. Does that make sense?

    Still working on this laptop today, and have house chores to finish up, but will take a further look later. Havn't checked out your site yet, but i'll take a look later when i have time to devote my full attention. Windows updates are a chore on a Celeron... (with only 256mb of ram).

  28. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    heh....

    I never thought of looking in my directories, but there they are

    I get a bunch of versions of each image I upload to accomodate the various sizes I have set up.

    so....how do ya think it works....on upload? Like when you upload an image it grabs the image, and makes a bunch of copies for the various sizes you've already determined?

    So...if I now make another size in my functions.php, and add it into my theme.....does it make another copy of the image....or posts that already exist with thumbnails won't be updated.....

    lol....I'm not expecting you to answer my questions actually, just thinking outloud in case anyone has input.....or for future reference for someone.

    Have fun with that laptop, I'm 'bout to start on my friends when I'm off work..... bleh......

  29. Mark / t31os
    Moderator
    Posted 4 years ago #

    I'm not sure i really understand the whole image functionality, we have the standard media features and those three sizes you set for images in the backend, then we have the new stuff, like cropping and post thumbnails, but i'm not sure these necessarily relate to one another, and how cropping works exactly i must admit is a little beyond me right now.

    I can't see we could add an on-the-fly(so to speak) cropping function to the default image, so i think that leaves us at... What do you want to do with the image exactly? What's the intended behaviour exactly(sorry if you covered this but i'm not sure i fully grasp the issue).

    Of course i think we need to bear in mind the things we're discussing here are new features and that they're not fully matured yet, there seems to be this air of confusion(at least for me) in regard to how to use them, and how they should be used in conjunction with the existing media features...

    I've been thinking about it quite a bit, and it's still not becoming clear, i think we need a fresh set of eyes or another opinion, somebody who can look at this from a different angle(or uses the features extensively).

    Off-topic: Laptop is finished at last, yay!.. :) Painful process, but done nonetheless...

  30. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    yeah....I think I'm just kind of having high hopes here. I can drop in the default image in my index.php, and single.php and get the behaviour I want, using multiple image sizes. It's what I've been doing thus far. I may have to stick that route.....which is fine...

    I was looking to have a default image called in through functions.php which when implemented would automatically use the single high-quality image I have in my theme, and resize it automatically according to the rules set by my various add_image_size options including proper crop. And it would also grab the extra attr stuff (class and alt) according to the class and alt added on index.php and single.php.

    This way, ultimately down the road, when I edited my theme, or especially when I got to building a new one, I didn't need to make extra image sizes....you know having 3 or 4 different 'default' images....instead having just the one that got resized appropriately and was reusable.

    It looks like it may not be possible.....but that's cool, something I just wanted to try to work through. Thanks for the help!! I have learned a fair bit so far, even without desired results!

    Off-topic: I got my friends laptop reformatted....still have to finish up....drivers and software, and making it 'user' proof, so I don't have to keep doing this!!

Topic Closed

This topic has been closed to new replies.

About this Topic