Last active
February 1, 2023 05:56
-
-
Save raselahmed7/14e1b7af019189eee286 to your computer and use it in GitHub Desktop.
Wordpress image crop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// in functions.php | |
add_theme_support( 'post-thumbnails'); | |
/* | |
Wordpress crop an image = 5 size. Sizes are given below | |
thumbnail // Thumbnail (default 150px x 150px max) | |
medium // Medium resolution (default 300px x 300px max) | |
large // Large resolution (default 640px x 640px max) | |
full // Original image resolution (unmodified) | |
But, if you need custom size, you can define sizes in functions.php | |
*/ | |
add_image_size( 'post-image', 600, 200, true ); | |
// Using the sized image in your loop | |
// Image URL | |
// If you want to use wordpress resize just add your size, I've added large size image in example | |
$image_variable = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' ); echo $image_variable[0]; | |
// If you want to use your custom size | |
$image_variable = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-image' ); echo $image_variable[0]; | |
?> | |
I like it.
চমৎকার হয়েছে
add_new_image Hard Crop Not Working
pls rasel vai how to solve this problem
Thanks Rasel vai..
Thanks Rasel vai.
Thanks Rasel Vai onk upokito holam
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fine