How to get the url of an Image with id
How to get the url of an Image with id
How to get the url of an Image with id
Due to Jacob Peattie’s comment I decided to exam the HTML around rather than beating around the src-bush and it turned out that the thing was the one causing problems. Once I took the image out of it, it displayed itself properly.
If you want to get those set in the admin panel, use the function get_option. The keys are get_option(‘thumbnail_size_w’); get_option(‘thumbnail_size_h’); get_option(‘medium_size_w’); get_option(‘medium_size_h’); get_option(‘large_size_w’); get_option(‘large_size_h’); If you want them for some specific attachment, use wp_get_attachment_image_src
I’ve figured it out. I had enabled hotlink protection. I installed the new blog in a new subdomain which was not added to the hotlink protection. So, it prevented the image requests. Now I added to the list and everything’s fine. Silly me. 🙁
Use plugin Regenerate Thumbnails to resize thumbnails. Edit: Try use filter “the_content” to convert in post content. <?php function foo ( $content ) { return preg_replace (‘/540×287/’, ‘525×279’, $content); } add_filter( ‘the_content’, ‘foo’ ) Filter “the_excerpt” if need convert excerpt too.
Use get_children() (Codex ref): $images = get_children( array( ‘post_parent’ => $post->ID, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’ ) ); The first image will be $images[0]. EDIT: And by “first image”, I mean, the $ID of the first image, which you can use with any of the myriad image- and … Read more
you can always just set a css tag display:none to the caption element
Moving is a royal pain indeed and everything goes into the details. A possible solution to these potential problems is a new plugin that was just released, it’s called the Duplicator: http://wordpress.org/extend/plugins/duplicator/ I haven’t tested it yet, just saw the news in my Reader, but saw the video and it looks pretty awesome. So you … Read more
I believe the alt attribute of the image is stored in post_content, isn’t it? To get the alt tag for an image with attachment ID $attachment_ID, you would just call: $alt_text = get_post( $attachment_ID )->post_content; To actually display the alt text dynamically on images that are already embedded in posts, you would have to do … Read more
You can do that programatically via wp_insert_attachment() function. Here is an example at WP Codex: http://codex.wordpress.org/Function_Reference/wp_insert_attachment