Use wp_get_attachment_image( $id )
.
Sample code:
print wp_get_attachment_image(
$main_image,
array ( 80, 80 ),
FALSE,
array ( 'alt' => 'portrait' )
);
Related Posts:
- How do I Add images uploaded in the post to a default custom field
- Add image URL automatically to custom field?
- WordPress Theme Preview Image
- The the_post_thumbnail without srcset?
- Get the first image from post content (eg.: hotlinked images)
- How to add a checkbox element to attachments editor with example
- How to modify an image block in Gutenberg WordPress 5?
- How can I set image sizes and still have responsive images using the srcset attribute?
- Add default Backgrounds
- Edit srcset and sizes attributes in Gutenberg image, cover and gallery – blocks
- Specify image dimensions
- How to get gallery images?
- add_image_size is scaling, even though crop is set to true
- Featured Image in 4.4 should be larger on mobile device
- How to use the responsive images feature from WP 4.4 in your themes
- Confused about image sizing business in WordPress
- Unexpected width and srcset attributes for the_post_thumbnail();
- How wordpress handle upload images and how to use them in the code
- Change loop order via form or link (jquery, not URL)
- Replace Home with image link inside custom header menu
- Featured Image Size
- inserting custom li class to wp_list_pages
- How to set dimensions of the post thumbnails (featured images)
- Add theme templates for child categories into the template hierarchy
- How to float an image in Gutenberg
- A mystery 300px image size
- Load child template based on parent
- Custom post fields
- Reasons why all thumbnail sizes aren’t working
- How to make a local cache of mshots images
- Injecting a custom sql query into a page/theme
- image url relative path not working in css file
- Default image size not working
- Custom Field created in add_meta_boxes reappearing itself again in the default Custom Metabox
- How do you replace content generated by custom fields with custom blocks in Block Editor?
- How to display all subpages and short by year
- Sort wp_query by sum of two meta fields
- What’s the best practice way of handling custom fields in different post formats?
- Responsive Images – crop don’t seem to work
- Custom page template with custom fields
- How do I include pre-installed images in a theme?
- Inserting images in multiple posts native gallery
- Can I get the ID of an inserted / linked image?
- Add attachment for all images in post
- Changing Header Image Every N Minutes/Seconds
- What is the meaning of WordPress’s recommended css classes and where are they applied?
- Redirect to another page using contact form 7? [closed]
- Gallery thumbnails very small
- Where WordPress Stores The Custom Fields Values
- Custom image size vs CSS sizing
- In creating a theme, how can i allow a user to change an image outside post/page content?
- Change Responsive Images Maximum Width of 1600px
- How To Pick Custom Size Of Uploaded Image In Theme Via the_post_thumbnail();?
- Change image size depending on page
- How to obfuscate theme directory URLs
- how to retrieve the image title for image Post Format
- Modify available templates (in dropdown)
- Theme logo metadata into template file
- WordPress creating images if uploaded image is greater than 960px on one side?
- How to add post meta fields to an article’s as meta elements
- Injecting pre-defined text from custom page template to editor
- How to fix WordPress images not showing up in local hosted XAMPP server?
- Let user to add input fields on theme option page
- Get attachment meta (I need attachment ID, unsure how to find it)
- How to use shortcode inside of shortcode in theme
- Change Image Sizes for Mobile Theme
- Stop WordPress from showing images on non post pages
- How to make excerpt image be full size instead of thumbnail?
- How to add cropped custom header image?
- Is there a way to serve different resolution images to different devices?
- How can I remove image taxonomy pages from my theme and from Google?
- Dynamic Image Links Depending on Excerpt/’Single Post’ View
- ACF get_sub_field ALT TAG in the repeater doesn’t show
- How can I add a field for featured image on backend of a custom Taxonomy?
- WordPress Animation Adjustments
- theme directory fallback image outputs url and not the image
- Post Featured Image Custom Sizing?
- Image cropping isn’t working correctly when using Offload Media
- How to add an image to a theme page template in code?
- How to fix a conflict cause by my theme with Woocommerce and/or Gravity Forms?
- Responsive Images with art direction
- Customizer Image-Picker Preview Not Working
- Make a custom field in admin post.php read only
- Can’t upload images on new theme
- Images use & location, on new wordpress theme
- How to show children pages as array
- image sizes – finding and removing
- Adding a Class to an Getting From Post Content
- Menu order of parent menu from perspective of child menu
- Create image with imagepng() (fails at header)
- How to add custom field option with menu?
- How do I keep images in posts below a certain size without editing the post?
- Add custom field to existing meta box?
- Any disadvandages if I style the wordpress align classes without img and .wp-caption prefix
- the_post_thumbnail fetches wrong image
- Retina ready for uploaded images which are cropped
- 404 on child page template
- How can I add a single image from a gallery into the page header?
- Isotope overlapping .items because of featured images – HELP! [closed]
- Custom Theme functions.php – Using add_settings_field and input type=”file” to set custom logo