Adding width and height to wp_get_attachment_image_src

What is ‘two’ referring to? Is that a custom image size? Place the following var_dump(‘<pre>’,$image,'</pre>’); after your declared $image variable like so, $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ‘two’ ); var_dump(‘<pre>’,$image,'</pre>’); and provide the results so we can inspect the output. As per Codex the second argument in this function, wp_get_attachment_image_src( $attachment_id, $size, $icon ); … Read more

Auto resize images after adding a new size

WordPress doesn’t regenerate the newly registered size, only applies it to future uploads. You’ll have to use something like the Regenerate Thumbnails plugin or one of the similar ones available at WordPress.org.

function to show only featured image of the posts

I am not sure that a filter on the_content is the way to go here. If I understand you, I think that all you need is something like the following your theme– cribbed from the two Codex pages listed below and altered slightly. if ( has_post_thumbnail() ) { // check if the post has a … Read more

Image popup in a lightbox / overlay from the backend 3.5 admin area (plugin)

You can just use the built in ThickBox. Maybe not the pretties library but it does its job. Just add the class thickbox to the link and add the image to the href Here is a simple example: <?php echo ‘<a href=”https://wordpress.stackexchange.com/questions/78749/image.png” class=”thickbox”>’. __(‘Test image’, ‘domain’) .'</a>’; ?> Read more about ThickBox here.

Shortcode for a link and thumbnail

You are assigning the attachment URL to your $url variable: $url = wp_get_attachment_url( get_post_thumbnail_id( $id ) ); then passing that same variable back to wp_get_attachment_url: return ‘<img src=”‘ . wp_get_attachment_url( $url ) . ‘”/><a href=”‘ . get_permalink( $id ) . ‘”>’ . get_the_title( $id ) . ‘</a>’; You should simply output it instead: return ‘<img … Read more

Get meta data from image

Image data is stored as if it were a post, or a CPT, so you can treat it like one. $album_id = get_the_id(); $img = new WP_Query(array(‘p’=>$album_id,’post_type’=>’attachment’)); var_dump($img->posts[0]->post_content); Or, a little more complicated,… $album_id = get_the_id(); $img = new WP_Query(array(‘p’=>$album_id,’post_type’=>’attachment’)); if (!empty($img->posts[0])) { var_dump($img->posts[0]->post_content); } get_the_ID will return the ID of the current post so … Read more

Image resize using url parmater

WordPress(.org) doesn’t have anything like this built into the core. A lot of theme developers use Timthumb to achieve that. The example you’ve linked to is on a wordpress.com server so there will be something custom going on for that functionality. You could also look at the WordPress functions add_image_size & the_post_thumbnail.

Customize WooCommerce Product Images (Placement and size) [closed]

The file responsible for generating the sidebar cart is mini-cart.php and is located in woocommerce/templates/cart/mini-cart.php What you do is you copy that file and paste it into YOURTHEMEFOLDER/woocommerce/cart/mini-cart.php Open up that file and edit line 40 where it contains <?php echo $_product->get_image(); ?>` Change that to <?php echo $_product->get_image( array( 50, 80 ) ); ?> … Read more