WAMP install acts different than live install when uploading images
WAMP install acts different than live install when uploading images
WAMP install acts different than live install when uploading images
well i look and i look and finally i found this work that work for me. $upload = wp_upload_bits( $_FILES[‘image’][‘name’], null, file_get_contents( $_FILES[‘image’][‘tmp_name’] ) ); $wp_filetype = wp_check_filetype( basename( $upload[‘file’] ), null ); $wp_upload_dir = wp_upload_dir(); $attachment = array( ‘guid’ => $wp_upload_dir[‘baseurl’] . _wp_relative_upload_path( $upload[‘file’] ), ‘post_mime_type’ => $wp_filetype[‘type’], ‘post_title’ => preg_replace(‘/\.[^.]+$/’, ”, basename( $upload[‘file’] … Read more
Seems like I managed to work . I put this code into upload code $check = getimagesize($_FILES[“file”][“tmp_name”]); if($check !== false) { $uploadOk = 1; } else { echo “File is not an image.”; $uploadOk = 0; wp_trash_post( $post_id ); } And this allow users to post just images and if he upload another file type … Read more
Hey I had the same problem about 4 5 days , until I found this code , try some tweaks and see if works 🙂 #Upload and Create attachment if (!function_exists(‘wp_generate_attachment_metadata’)){ require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/file.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/media.php’); } $upload = wp_upload_bits( $_FILES[‘file’][‘name’], null, file_get_contents( $_FILES[‘file’][‘tmp_name’] ) … Read more
First deactivate any caching plugins you may have and delete their caches. Then delete all browser data on all devices. This is the most probably cause for this. On reactivation, things should get back to normality.
You are right that global $post is not set inside the function. Because it is Ajax callback and there is no loop. However Ajax call is sending post ID which you can retrieve as $_POST[‘post_id’] inside the function. Please note: In callback function arguments $url is not the image URL. It is anchor tag URL. … Read more
Are you trying to upload a featured image/a thumbnail for a post? If that’s the case, then it will have to be resized like that. If you are not, try clicking on the ‘Edit Image’ option on the ‘Insert Media’ section and try messing around with the settings there. Regards, CSCoder.
So what’s wrong with adding in the attributes as Mark is saying? <?php $thumb = get_post_thumbnail_id(); $img_url = wp_get_attachment_url( $thumb,’full’ ); $image = aq_resize( $img_url, 150, 200, true, true, true ); ?> <img src=”https://wordpress.stackexchange.com/questions/223038/<?php if($image) { echo esc_url($image); } else { echo catch_that_image();} ?>” width=”150″ height=”200″ alt=”<?php echo get_bloginfo(‘name’); ?>”/>
I’ve seen this kind of sites or even worked on it. You can add custom sizes from your theme’s functions.php file using add_image_size(). This may help you https://developer.wordpress.org/reference/functions/add_image_size/ Based on your requirement I think this would help you too http://www.wpexplorer.com/wordpress-image-crop-sizes/ Feel free to ask any queries.
I had to code an external program, I can’t see any other way. I used Java JDBC in my case. Query: SELECT p.post_title, m.meta_value FROM wp_term_taxonomy tt INNER JOIN wp_term_relationships tr on tt.term_taxonomy_id = tr.term_taxonomy_id inner join wp_posts p on p.ID = tr.object_id inner join wp_posts p2 on p.ID = p2.post_parent inner join wp_postmeta m … Read more