Link to full size image or attachment page in photo theme
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), “full” ); echo ‘<a href=”‘ . $image[0] . ‘”>Link to Full Size</a>’;
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), “full” ); echo ‘<a href=”‘ . $image[0] . ‘”>Link to Full Size</a>’;
Generally speaking, there’s no need to do this. However, if it’s one added using add_image_size, it will be in the $_wp_additional_image_sizes global. global $_wp_additional_image_sizes; echo $_wp_additional_image_sizes[‘small’][‘width’];
I don’t think that you can use get_the_post_thumbnail function to get last uploaded media, but you can use get_post to get latest attachment and then wp_get_attachment_image to display images. $attachments = get_posts( array( ‘post_type’ => ‘attachment’, ‘posts_per_page’ => 1, ‘post_status’ => null, ‘post_mime_type’ => ‘image’ ) ); foreach ( $attachments as $attachment ) { echo … Read more
You should use the built-in WordPress media manager to attach/insert images in posts. That way, if you define $content_width appropriately, WordPress will auto-resize large sized images to fit accordingly. Otherwise, you’ll have to rely on using CSS to set the max-width property for images within your content container (e.g. #content img{ max-width: 500px; height: auto; … Read more
I’m glad that better support should be added in version 3.4 but for now I’ve fixed the issue by changing the behaviour of image insertion so that it doesn’t use the shortcode. Here’s what I added to functions.php: add_filter( ‘disable_captions’, create_function(‘$a’, ‘return true;’) ); function image_send_to_editor_2($html, $id, $caption, $title, $align, $url, $size, $alt) { if … Read more
Refer to the add_image_size() Codex entry: <?php add_image_size( $name, $width, $height, $crop ); ?> The $crop parameter is the key: (boolean) (optional) Crop the image or not. False – Soft proportional crop mode ; True – Hard crop mode. Default: false That is: False (default): box-resize – (resize image against the constraining dimension) True: hard-crop … Read more
You’re obviously getting data returned for $attachments = get_posts(); otherwise, you wouldn’t be able to output $attachment->post_title. So the issue must be with your wp_get_attachment_image() call. The first thing I would check is: why are you setting the $icon parameter to true? This parameter is intended to output a mime-type icon, instead of the actual … Read more
Use switch_to_blog to switch blog contexts to a specific blog ID. From there on it’s all down to get_posts of the attachment type. And switching back to the current context with restore_current_blog. Something like this: switch_to_blog( $blog_id ); $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => 5, ‘orderby’ => ‘post_date’, ‘order’=> ‘ASC’ ); foreach ( … Read more
In Advanced Custom Fields the field editing screen where you add in the required fields and assign them to post edit screens did you choose image URL or Attachment ID for the image field? It sounds like you’ve got it set as image URL which will just return the URL to the originally uploaded file … Read more
Yes, you can use any slider jquery plugin you wish, but to feed the slideshow you need the photos. Galleries in WordPress are composed of posts with post_type attachment, and attachments that are attached to a post have that posts ID as their post_parent. So to get the images for the slideshow or slider, you … Read more