how to get original image using wp_get_attachment_image_src
Try this : wp_get_attachment_image_src( $PriImgId, ‘full’ ); Also, for more options see the Codex.
Try this : wp_get_attachment_image_src( $PriImgId, ‘full’ ); Also, for more options see the Codex.
There are four valid sizes built in to the WordPress core. the_post_thumbnail(‘thumbnail’); // Thumbnail (default 150px x 150px max) the_post_thumbnail(‘medium’); // Medium resolution (default 300px x 300px max) the_post_thumbnail(‘medium_large’); // Medium Large resolution (default 768px x 0(means automatic height by ratio) max) since WP version 4.4 the_post_thumbnail(‘large’); // Large resolution (default 640px x 640px max) … Read more
The only time setting the quality really matters is right before the image is saved or streamed (for the editor). Both of these have the “image_editor_save_pre” filter there, passing it the instance of the image editor. So you can use that to modify the image in any way you like, including setting the quality. So, … Read more
Ok, I’ve been playing with this for a little bit and have managed to change the output of the Gallery block, with the following caveats: The preview does not match the output. I think this is possible but appears to be a bit more involved. Certain classes and markup are required in the output for … Read more
function wp_get_attachment( $attachment_id ) { $attachment = get_post( $attachment_id ); return array( ‘alt’ => get_post_meta( $attachment->ID, ‘_wp_attachment_image_alt’, true ), ‘caption’ => $attachment->post_excerpt, ‘description’ => $attachment->post_content, ‘href’ => get_permalink( $attachment->ID ), ‘src’ => $attachment->guid, ‘title’ => $attachment->post_title ); } Source As sporkme explains later in the thread, this is dumped into your functions.php and can then … Read more
The add_image_size( $name, $width, $height, $crop ) function is graceful enough to handle multiple calls using the same $name. It simply overwrites the existing value: $_wp_additional_image_sizes[$name] = array( ‘width’ => absint( $width ), ‘height’ => absint( $height ), ‘crop’ => (bool) $crop ); So that means that all you need to do to override the … Read more
When an image size is added either by WordPress(add_image_size), or by a plugin or your own custom code it gets added into the $_wp_additional_image_sizes global, i can’t find a similar function for pulling data from that global, but you could certainly just look inside the global to determine what width and height a registered image … Read more
To remove the medium_large image size you can try to remove it with the intermediate_image_sizes filter: add_filter( ‘intermediate_image_sizes’, function( $sizes ) { return array_filter( $sizes, function( $val ) { return ‘medium_large’ !== $val; // Filter out ‘medium_large’ } ); } ); Not sure if you’re trying to remove all the intermediate sizes, but then you … Read more
There’s actually a great function that will do all three of those things for you: media_sideload_image( $url, $post_id, $description ); The first argument is the remote url of the image you want to download. The second argument is the post id of the post to which you want to attach the image. The third argument … Read more
This is another approach than the other answer that works when importing content with the importer and fixes the URLs once and for all. Again: This is not battle-tested but is the solution I settled on and it did work. I prefer this as it solves the issue once and for all and if it … Read more