New answers tagged

0

You can set post featured image space with css. like this: img.featured_image{ width: 50px; height: 50px; }


0

I tried to update the image size with: add_image_size( 'medium_large', 600, 255, array( 'center', 'top' ) ); But when i update the image size with height, width and crop, wordpress is just using the "large" image-size. When i just use add_image_size with the width argument: add_image_size('medium_large', 600, '', true); The image size gets updatet to ...


0

You can call add_image_size() again to update the existing image size. Assuming it is called medium_large (Events Manager Pro is a paid plugin so not very much people have it) you can do something like: <?php function update_medium_large_size_wpse216595() { add_image_size( 'medium_large', 600, 255, array( 'center', 'top' ) ); } add_action( 'init', ...


0

Okay. Got it working.... I used the simple version: add_filter( 'admin_post_thumbnail_html', 'basic_add_opacity_to_feature_thumb_box'); //same as before function basic_add_opacity_to_feature_thumb_box( $myhtml ) { $selected_option = get_post_meta( get_the_ID(), 'basic_opacity', true ); // get the current value for ( $i = 0; $i <= 1; $i = $i + 0.1 ) { ...


3

You got it quite right, but with a few minor problems. First, please use a uniqe prefix for your functions and values - opacity or meta_save are quite generic and could be used by other authors. Second, the part where you get the meta opacity was missing, I added it for you - just retrieve the meta value from the current post. Third, I then created a ...


0

I would try adding set_post_thumbnail_size( 250, 250, false ); In the theme's functions.php. (see codex on Setting Thumbnail Size)


0

Try the answer here: http://stackoverflow.com/a/13575967 To repeat the code from that answer: function featured_image_requirement() { if(!has_post_thumbnail()) { wp_die( 'You forgot to set the featured image. Click the back button on your browser and set it.' ); } } add_action( 'pre_post_update', 'featured_image_requirement' );


2

Life can be simple: Instead of the_post_thumbnail I should use get_the_post_thumbnail echo get_the_post_thumbnail($page->ID)


1

You can make use of the queried object. On the blog page, the queried object will hold the page object of the page set as blog page. The following will work (This is if you just need to show this on the blog page) /** * Use $post as local variable in order use setup_postdata * in order to make the use of template tags available */ if ( is_post_page() ...


1

In your example, $posts_page contains the ID of the page for posts, you can use that with any API function that accepts a post ID. For the featured image: $posts_page = get_option( 'page_for_posts' ); $post_thumbnail_id = get_post_thumbnail_id( $posts_page ); $url = wp_get_attachment_image_src( $post_thumbnail_id, 'your-custom-size' ); echo $url; And ...


0

It is for EXIF data. But if that's the code you're using, it looks like you are trying to access array elements on a function call. Try $my_data = wp_get_attachment_metadata( get_post_thumbnail_id( get_the_ID() ) ); echo $my_data['image_meta']['credit'];


2

This is sort of an alternative solution to doing a bunch of RegEx. Query all images attached to the post, get the thumbnail of the first and display it as thumbnail ( you could even assign it as the post thumbnail if you wanted to, to make it easier next time the loop is run ). So inside your loop you would have: if( have_posts() ) { $image_mimes = ...


0

From my experience if an ajax call in wordpress returns 0, it means that ajax can't find the related php function, so check three times that the function you point to in 'add_action', function name and the action of your form do match. I usually include an action attribute in the ajaxSubmit options as well, maybe it solves your problem. Just add action : ...


0

The feature became available with Version 2.9. Note that you can optionally pass a second argument with an array of the Post Types for which you want to enable this feature. add_theme_support( 'post-thumbnails' ); add_theme_support( 'post-thumbnails', array( 'post' ) ); // Posts only add_theme_support( 'post-thumbnails', array( 'page' ) ); ...


1

Get the image ID from the URL with attachment_url_to_postid(): $image_id = attachment_url_to_postid( $image_url ); Convert the ID to the thumbnail image URL with wp_get_attachment_image_src: $thumbnail_url = wp_get_attachment_image_src( $image_id, 'thumbnail' );


5

I want to disable the srcset only when calling a specific thumbnail size (for example only when calling full image size). Here are two ideas (if I understand you correctly): Approach #1 Let's check the size from the post_thumbnail_size filter. If it matches a corresponding size (e.g. full) then we make sure the $image_meta is empty, with the ...


1

get_the_post_thumbnail ( $post/$post_id, $sizes, $attr ) will give you the featured image as html to output. get_post_thumbnail_id ( get_the_ID ( ) ) will give you the ID of the featured image so you can use it to get more information. Getting the thumbnail ID is essentially accessing the the post's meta data: $image_id = get_post_meta( $post->ID, ...


1

$url = wp_get_attachment_url(get_post_thumbnail_id(get_the_ID())); above code get current featured image url. I hope it work for you.



Top 50 recent answers are included