all images of past post messed up after changing theme

Alignleft looks like it’s behaving itself exactly as it should: aligning the image left and the text to the right of it. If you want your left aligned images to behave the same way as you ‘align none’ image, simply go to your style.css and remove ‘float:left’ from your .alignleft code: .alignleft { float: left; … Read more

How do i replace the title attribute of img tag with the image caption

// Replace the title of img tag with image caption function wpdocs_filter_gallery_img_atts( $atts, $attachment ) { $attachment = get_post( $attachment->ID ); if ( $caption = $attachment->post_excerpt) { $atts[‘title’] = $caption; } return $atts; } add_filter( ‘wp_get_attachment_image_attributes’, ‘wpdocs_filter_gallery_img_atts’, 10, 2 ) This function is working for me local host but some how not working on the … Read more

set specific dimension or minimum upload size [duplicate]

Add these code to your theme function file. add_image_size(‘mythumb’, 350, 200, array( ‘left’, ‘top’ )); // third parameter is for cropped option, you can change that as your preference. the_post_thumbnail( ‘mythumb’ );// image with the new dimensions. Important: you need to regenerate thumbnails to make this work. You can use plugin for that. For complete … Read more

Issue uploading images

Are your WordPress URL and Site Address URL the same? I had a similar issue whereby one had a backslash and the other didn’t which caused it. Also, could you try inspecting the element in Chrome or Firefox and seeing where the URL points? Can you get to this URL directly from the browser?

Small image resizing for big! Alternative to timthumb

If you’re always blowing up a small image to a larger size, and don’t care about the resulting loss in quality (although personally I would, for photos at least) then you might as well simply override the height and width in CSS (or inline HTML) – there’s no gain in making the image file on … Read more

Different image margins on different pages CSS [closed]

You would need to recode your CSS a little. Since you have your beer image in its own container that helps. But you’d want to adjust the CSS: .beer-description{ float: left; width: 70%; } You can tweak it as needed. To not worry about the image size, you should have a width set (can be … Read more

Display images in template file

if You wish to display an image, which is a thumbnail of a post, then use: <?php echo get_the_post_thumbnail( $pageID, ‘thumbnail’ ); ?> if You wish to display an image from media, then use <?php echo wp_get_attachment_image( $attachmentID, ‘thumbnail’ ); ?> thumbnail is set for size and is set by default. Size can be changed … Read more

SVG files and wordpress

You’re going to have to edit your functions.php file and add a few lines. This article has a better explanation. I suggest you try here if you haven’t already. https://css-tricks.com/snippets/wordpress/allow-svg-through-wordpress-media-uploader/

If file exists with page slug name show image else nothing

EDITED ANSWER – First get the full file path to your image and store it to a variable $filename. Use file_exists to check if image exists, and output the image and with it the title of your image. If the condition fails, there is no output. https://codex.wordpress.org/Function_Reference/wp_upload_dir <?php global $post; $slug = get_post( $post )->post_name; … Read more