Tag Info

New answers tagged

3

You can try to add 'meta_key' => '_thumbnail_id', to your input arguments: $args = array( 'numberposts' => 5, 'orderby' => 'date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish', 'meta_key' ...


3

use add_image_size() to define you custom image size 1.register custom image size (functions.php) if ( function_exists( 'add_image_size' ) ) { add_image_size( 'custom-image', 440, 265, true ); //(hard cropped) } 2.get image in custom image size except featured image of post (functions.php) function ravs_get_custom_image( $featured_img ){ global ...


1

Check this Wordpress plugin Wp Retina 2X


1

You can alter the content of that meta box, which is unusual. Proof of concept: function alter_thumb_box($content, $postID) { return $content.'<input type="radio" name="thumb-size" value="" />'; } add_filter( 'admin_post_thumbnail_html', 'alter_thumb_box', 1, 2 ); You just need to add your fields and then provide a function to save the data, ...


1

You could add a meta box to the post add/edit screen below the featured image box to allow selection of size via a dropdown select menu. You could generate the list from available sizes (via get_intermediate_image_sizes), or just use your small/large strings. The data would be saved as post meta and you would simply get_post_meta() to get the selected size, ...


0

So if you know your height of image is 300px, then not put height auto in css make it 300px. ( or adjust height according to your design ) img { display:block; width:100%; height:300px; }


3

In this case I would add image size in functions.php which registers new image size in my theme and get the re-sized image. Example: Register custom image size (functions.php) if ( function_exists( 'add_image_size' ) ) { add_image_size( 'custom-image', 440, 265, true ); //(cropped) } Get custom image size (functions.php) function ...


-2

you would need to edit the themes css and add a rule for that image there. you could just specify the size of the image with css


0

you can always do a new wp_query to get the latest post from given category and display its thumbnail etc.. Something like $new_query = new WP_Query( 'cat=your_category_id&showposts=1' ); if( $new_query->have_posts() ): while( $new_query->have_posts ): $new_query->the_post(); the_post_thumbnail(); endwhile; endif; wp_reset_query(); replace ...


1

Sorry, but I don't see any of those parameters in the parameter list for wp_get_recent_posts. $args = array( 'numberposts' => 10, 'offset' => 0, 'category' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'include' => , 'exclude' => , 'meta_key' => , 'meta_value' =>, 'post_type' => ...


0

Take a closer look at your echo: you'll need to add your $default_attr to your get_the_post_thumbnail: <?php echo get_the_post_thumbnail( $post_id, $size, $default_attr ); ?> There are also a lot of good examples at the Codex: get_the_post_thumbnail UPDATE: As @Kratos pointed out, the code aboce will only echo the image (the title of $default_attr ...


0

To solve you problem <?php $pages = wp_get_recent_posts(); ?> <ul> <?php foreach ($pages as $page): ?> <li> <?php $attachment_id = get_post_thumbnail_id( $page->ID ); $attachment = get_post( $attachment_id ); ?> <img src="<?php echo ...


0

a non js solution without hacking the core. try this in your themes function.php add_filter( 'wp_get_attachment_image_attributes', 'remove_image_text');function remove_image_text( $attr ) { unset($attr['alt']); unset($attr['title']); return $attr;}


0

Use FPW Category Thumbnails plugin. It does exactly what you need and no coding is required. Map images to their respective categories. If you have many posts already use Apply Mapping button and all posts belonging to the category which has an image mapped to it will get this image as a thumbnail. From this point on everything is automated. When you create ...


0

You need to first download those external images then you can attach and set them as the post thumbnail. To download and attach you can use the media_handle_sideload() function. I wrote a plugin that will search through all your posts and pages and download and attach any external image into the media library. It also has the option of setting the first ...


-1

you can hook yourself into save_post and check there if the image is present. if it is not there fire an admin_notice. more here http://wordpress.stackexchange.com/a/15355/32776 http://codex.wordpress.org/Plugin_API/Action_Reference/save_post Edit: I dont have the time to provide working code but here is a copy paste from the links above. i think that you ...


0

I've just had this same issue and the answer for me was regenerating thumbnails as bryceadams suggested (I don't have enough points to vote for his response unfortunately). Caveat: The images must be stored locally not remotely. Presumably no thumbnails are generated for remote images.


0

I don't think this is possible. I've been searching for something like this as well and haven't come up with a solution. Here is a post I found that may get you headed in the right direction: http://wordpress.org/support/topic/how-to-set-different-thumbnail-sizes-per-custom-post-type


0

Well i use some different kind of code, which make custom post, but it work perfectly. which save tags,category,freature image. Here is code, Hope fully its help you. function my_custom_post_faq() { $labels = array( 'name' => _x( 'Slides', 'post type general name' ), 'singular_name' => _x( 'Slides', 'post type ...


1

A quick experiment with WordPress 3.5.1 shows that when you an image into post from URL, there's no post inserted into the wp_posts or wp_postmeta table - which is why the $images array is coming back empty. You could write some JS on the admin side to create and insert a post asynchronously when you click the insert into post button - otherwise, you could ...


1

If I am reading your question correctly, the problem is that when you set a page so that it has a an archive Loop on it $wp_query and the $posts variable are set to for the index Loop and not for the page the are on. To get information about that page you need get_queried_object. Two lines will show your featured image. $obj = get_queried_object(); echo ...


0

Yes your question makes sense. My understanding of the image attachments in WP is that you upload an image and it gets resized to all defined sizes currently defined in your instance of WP. So you can't specify a given size for a given image upload. And therefore, there is no way of ascertaining what a specific image's size should be. I expect the size ...


0

In the query, you should use the_post_thumbnail. <?php the_post_thumbnail( $size, $attr ); ?> The size is a keyword or an array, and the attributes are for the image tag. So, something like <?php the_post_thumbanil('large', array('class' => 'my-class')); ?> will output: <img src='img-large.jpeg' class='my-class' /> You can ...


2

wp_get_attachment_thumb_url() does not accept size as argument. You might be looking for wp_get_attachment_image_src(), but I am not sure on top of my head - too many functions in that corner.


1

Got it to work by using ACF's custom functions instead of wp's meta functions. Final working result: //Set post thumbnail based on various conditions if (get_post_meta($post_id, 'featured_image', true)) { $attachment_id = get_post_meta($post_id, 'featured_image', true); } elseif (get_post_meta($post_id, 'upload_single_image', ...


2

You have to set the $single paramter of get_post_meta to false (or don't set it) to get an array. Here is a sped-up version: if ($attachment_id = get_post_meta($post_id, 'featured_image', true)) : elseif ($attachment_id = get_post_meta($post_id, 'upload_single_image', true)) : elseif ($attachment_id = get_post_meta($post_id, 'create_gallery', ...


0

As mentioned above, this link can help you on your way: http://codex.wordpress.org/Post_Thumbnails You need to add thumnail sizes to your functions.php like: the_post_thumbnail(); // without parameter -> Thumbnail the_post_thumbnail('thumbnail'); // Thumbnail (default 150px x 150px max) the_post_thumbnail('medium'); // ...


2

First, exclude the featured image (= post thumbnail) from the query, then set up the posts array as combination of the featured image and the other images. Put this directly below $args = ... and above $attachments = ...: if (has_post_thumbnail($post->ID)) { $featured_image = get_post_thumbnail_id($post->ID); $args['exclude'] = ...



Top 50 recent answers are included