Tag Info

Hot answers tagged

2

it is much easier with WordPress inbuilt function media_handle_upload http://codex.wordpress.org/Function_Reference/media_handle_upload // These files need to be included as dependencies when on the front end. require_once( ABSPATH . 'wp-admin/includes/image.php' ); require_once( ABSPATH . 'wp-admin/includes/file.php' ); require_once( ABSPATH . ...


1

You should not use the_ID() in this case, since it will echo the ID, use instead get_the_ID() to return it. So please try this instead: $thumb_id = get_post_thumbnail_id( get_the_ID() ); to get the ID of a post thumbnail image. The general rule is that the_*() functions will echo the output, but get_*() functions will return it. But of course there ...


1

0 should work as a height in your thumbnail settings. The only other issue is that your uploaded images might be smaller than the large media size you're inputting. Image thumbs won't be scaled up for obvious reasons. If your images are larger than your thumbnail setting and you're still not seeing thumbnails generated then: Check your server logs Try ...


1

Per the Codex entry for the_post_thumbnail(), passing an array has not worked since WordPress 3.0: PLEASE NOTE: The crop does not work in WP 3.0+. All that is needed for WP 3.0+ is the call for the thumbnail to post. Then proceed to media in the dashboard and set your thumbnail to crop to the size you wish to use. The correct implementation is to ...


1

You can wrap the image in a figure. <!-- html --> <figure class="constrained-container"> <img src="my-image.jpg" alt="What my image is about"/> </figure> Then style the figure as well as the image. /* css */ .constrained-container { height: 300px; overflow: hidden; /* this hides excess of the image */ } ...


1

$port_query->the_post(); should set the $post global. That isn't the problem. The problem is that the you are trying to use $post before your secondary Loop runs (99% sure). You've hooked the bkg_featured_image() function to wp_head. wp_head runs in the header of the document, which, unless you are careful, will run before the other template code. If ...


1

You have a variable scope problem. $post_id = wp_insert_post($post_information); function upload_user_file( $file = array() ) { require_once( ABSPATH . 'wp-admin/includes/admin.php' ); $file_return = wp_handle_upload( $file, array('test_form' => false ) ); // ... You set $post_id outside of your upload_user_file() function but that ...


1

You are misreading the Codex. wp_get_attachment_image_src() works just fine with custom image sizes. Proof of concept: // copied from the Codex // https://codex.wordpress.org/Function_Reference/add_image_size if ( function_exists( 'add_image_size' ) ) { add_image_size( 'category-thumb', 300, 9999 ); //300 pixels wide (and unlimited height) ...



Only top voted, non community-wiki answers of a minimum length are eligible