Articles of wp get attachment image

Creating page templates with image placeholders

I am creating my own theme and in the design I received for the theme I have a few pages which have 2 images of different dimensions. One is at the top (like a banner of sorts) while the other one is on the right side of the content text. So underneath the banner there […]

Image is not displayed in overridden woocommerce email

I have overridden woocommerce customer-completed-order.php <?php if ( ! defined( ‘ABSPATH’ ) ) { exit; } do_action( ‘woocommerce_email_header’, $email_heading, $email ); ?> <p><?php printf( __( “Your recent order has been completed.<br> ,’woocommerce’ ) ); ?></p> How to add image to the end of the email? I tried <?php echo wp_get_attachment_image( 1096 ,add_image_size(‘logo-size’, 219,98) ); ?> […]

use wp_get_attachment_image() to show attachments

I really hope this is a facepalm moment, b/c i’m getting frustrated with this. Making a quick loop to show certain attachment images. lifted it almost straight from the codex but wp_get_attachment_image() isn’t behaving like I’d expect. isn’t the ID part of the wp_get_attachment_image the ID of the attachment? is that not the same as […]

File format of post image attachment

I’m working on a website that can display 3D molecules (.mol) using the JavaScript-based viewer from JSmol (http://sourceforge.net/projects/jsmol/). With the “Upload File Type Settings” plug-in files with .mol extension can be uploaded as “Featured Image”. I managed to customize my single.php template with the JSmol script to display the .mol files. Now I’d like to […]

Removing width and height attributes from wp-get-attachment

I’m using this http://www.ghosthorses.co.uk/production-diary/removing-inline-img-dimensions-for-responsive-wordpress-websites/ to remove the height and width attributes of images. Everything works fine except that it messes up the masonry container because of the images have no height. How could I apply this filter only to a determined div id/class?

Get the size (size in Kb or MB) of an featured image?

I need to display some featured image info on post page. Among other info I need to display file size of image (featured image of post). I tried this function inside single.php. <?php function getSize($file){ $bytes = filesize($file); $s = array(‘b’, ‘Kb’, ‘Mb’, ‘Gb’); $e = floor(log($bytes)/log(1024)); return sprintf(‘%.2f ‘.$s[$e], ($bytes/pow(1024, floor($e)))); } ?> and […]

How to add an image for unit testing?

I have to test the function where it calls wp_get_attachment_image_src. How do I add an image for testing, because right now if I call this method it returns false.

Change code to display image attachment page

I have this code which displays images with their captions in a list. On clicking caption, opens image in an attachment page, but clicking on image, opens that image with a dark-gray background. Is there a way to display image on attachment page on clicking on it?? I played alot with it, but no success. […]

change wordpress gallery shortcode to slider

Hi I wanted to change the default WordPress gallery short-code and make it a slider. remove_shortcode( ‘gallery’ ); function gallery_filter( $atts, $content = null ) { extract(shortcode_atts(array(‘gallery_name’ => ”), $args)); $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => 3, ‘post_parent’ => $post->ID, ‘order’ => ‘ASC’, ‘orderby’ => ‘menu_order’, ‘post_mime_type’ => ‘image’ ); $output .= ‘<script […]

How to use the responsive images feature from WP 4.4 in your themes

I don’t really understand how I can use the new responsive images feature that WordPress provides in my themes. Example: In my theme, I add a header-image. I therefore use the custom-header-image from customizer OR the post-thumbnail: <figure id=”header-image” class=”uk-margin-remove”> <?php if ( ( is_single() || ! is_home() ) && has_post_thumbnail() ) : ?> <?php […]