Custom Field returning Numerical Value for Image rather than URL
Use wp_get_attachment_image( $id ). Sample code: print wp_get_attachment_image( $main_image, array ( 80, 80 ), FALSE, array ( ‘alt’ => ‘portrait’ ) );
Use wp_get_attachment_image( $id ). Sample code: print wp_get_attachment_image( $main_image, array ( 80, 80 ), FALSE, array ( ‘alt’ => ‘portrait’ ) );
Who would say the solution would be this simple… After days battling with this, somehow it struck me: “what if we switch_to_blog() inside the media upload iframe?” What if we require the user to save the post before uploading any images? Turns out I had no answer to why we weren’t doing this on the … Read more
You should reorganize the way you store the images: Make the uploaded files children of that particular post, do not put them in a post meta field. Then get all the images with get_children(). Look at the built-in handler for the shortcode for some examples. I should go like this: $args = array( ‘post_mime_type’ => … Read more
Use the second parameter of wp_get_attachment_image_src(): $size. $att = wp_get_attachment_image_src( $att_ID, ‘large-thumb’ ); or $att = wp_get_attachment_image_src( $att_ID, array ( 900, 300 ) ); The size is passed to image_downsize() and there to image_get_intermediate_size(). If $size is an array WordPress will search for the best match in existing images: // from wp-includes/media.php::image_get_intermediate_size() // get the … Read more
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
The following ought to be much closer to what you want to achieve: <div class=”imgHentry”> <a href=”https://wordpress.stackexchange.com/questions/74228/<?php the_permalink(); ?>” class=”goto-icon”> <?php the_post_thumbnail( ‘thumbnail’, array( ‘alt’ => get_post_meta( $post->ID, ‘alt_tag’, true ) ) ); ?> </a> </div>
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.
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
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.
From codex: The the_author_meta Template Tag displays the desired meta data for a user. If this tag is used within The Loop, the user ID value need not be specified, and the displayed data is that of the current post author. A user ID can be specified if this tag is used outside The Loop. … Read more