Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

How to get custom field image url of specific size

The get_post_meta() function can help to get the meta field but will not retrieve different size.

Assuming _pf_photo1 embed the attachment id, you can do something like that:

// Note the "_id" suffix
$attachment_id = get_post_meta($post->ID, '_pf_photo1_id', true);

Last parameter for this function can not be ‘medium’,

Now,you can use $attachment_id with different function depending on what you really want to get (url, img element…):

$attachment_element = wp_get_attachment_image( $attachment_id, 'medium' );
echo $attachment_element;

There is more ways to get details for attachment wp_get_attachment_url(), wp_get_attachment_image_src (that returns an array with url, width, height).

You will find more details to discover these functions here

Hope it helps !

Related Posts:

  1. Set attached to state
  2. How to change ID of an attachment in wp_posts and its related tables correctly?
  3. Make the checkbox meta field checked by default
  4. Assign / update custom field value for all posts (How can I assign only to posts without custom field value?)
  5. “After file loaded” action
  6. What snippet do I need to type to show my ACF field show up on my theme?
  7. Is there a way to make [Table Of Content] plugin while not using revision data?
  8. get_post_meta shortcode returns empty field
  9. How to get post that has non zero or greater than zero meta value
  10. How to display the “ratingValue” and “ratingCount” values ​generated by the KK Star Ratings plugin into my page’s recipe ld+json schema
  11. Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
  12. get current date + 90 days and checking every day
  13. auto populate list of questions if user select a category xyz
  14. is there a way to link one of the field in ACF field group, to a field in a media attachment page? [closed]
  15. How to toggle between two custom fields in WordPress woocommerce ‘WC Product Field Group’ plugin?
  16. How to create an input field, and base the output on spreadsheet data? [closed]
  17. How do I hide posts across all loops based on the value of a custom field?
  18. How can I change the meta_key for a particular piece of information?
  19. WordPress Post Visibility Options for Frontend
  20. Custom User meta field display
  21. Bulk update all posts from plugin settings screen
  22. Execute js files doesn’t seem to work
  23. WordPress metaboxes – textfield suggestion automatically populated
  24. Char limit on custom blog-post form? [closed]
  25. Unable to select image using custom image field type
  26. Custom fields for custom post type
  27. Redirect to another page using contact form 7? [closed]
  28. Every new post/draft has a custom field variable “yst_is_cornerstone” showing
  29. Custom Post Type Fields
  30. Meta box losing its value when scheduled post is published
  31. How to insert multiple postmeta values with one query?
  32. How do I enforce users to fill a determined custom field using WyPiekacz?
  33. Mass SQL WordPress Meta Key deletion
  34. Date format – Meta Box plugin
  35. get meta value from database by post id
  36. Adding class to last list item? Not WP generated
  37. How to Resize the Custom Post Images?
  38. Amazon.com intergration with WordPress?
  39. Sticky option for custom post types without using custom fields or plugins
  40. How to remove bulk actions from custom post type
  41. Adding custom meta boxes to specified custom post type
  42. How to select a paragraph other than the 1st to be the post’s excerpt?
  43. How do we update a custom file upload field with the Advanced Custom Field plugin?
  44. Set Multiple Meta Values as an Array Using dispatch( ‘core/editor’ ).editPost() Call in Gutenberg/JS
  45. Order posts by meta key ( Using ACF )
  46. How to add fields in the WordPress editor?
  47. How can I concatenate variables to search results title? [closed]
  48. WordPress function to add text warning on every pages [closed]
  49. Search by Attachment ID
  50. JSON API Plugin not showing Attachments id reused
  51. How to add an extra, independent set of custom fields?
  52. Price comparison table based on Custom Post Type?
  53. Show related posts based of current ACF field name in a single page post (a loop within loop)
  54. How can I store data from custom fields to custom tables?
  55. Remember the Meta Value With Radio Buttons
  56. Woocommerce – Change Variable Product Add to Cart to behave like external product using Custom Field (link) [closed]
  57. Attachments broken after giving WordPress its own directory
  58. Custom Fields for Page Edits
  59. Plugin that lets visitors Like a post (not facebook) and stores likes in custom meta?
  60. Parent Child Custom Fields with Advanced Custom Fields
  61. grab or load text on demand
  62. How can I add user profile fields to my mailpress mailout
  63. Dictionary-style definition list plugin
  64. Advanced Custom Fields Plugin – Images not displaying
  65. Link Posts to External URL
  66. Adding custom Field To The Posts Listing
  67. How to create repeater field manually, without plugin (ACF Pro)?
  68. Creating New Dynamic Fields for a Certificate (Number Generation, Code Referencing, and more)
  69. Why does “updated_post_meta” did not fire when uploading media other than image?
  70. WordPress Phone Field Check (use numbers, spaces and pluses)
  71. Can export gallery but can’t import it Wp all import
  72. Table of contents (TOC) plugin is not showing header tag
  73. Auto populate a user custom field from another user custom field
  74. Best approach to make all tags searchable by the wordpress search function
  75. need to find duplicated meta value in custom filed and view the posts that have the same value
  76. Create a pdf from the entries in DB
  77. Help with autofilling field
  78. Help to Create a Simple Plugin to make a post
  79. how to find out which plugin disable custom field for post
  80. Preset custom fields
  81. What database state changes happen after a post is manually “updated” with no changes?
  82. submit two file input fields in the same form
  83. Register PODS Custom Field with WPGraphQL [closed]
  84. Get all image in media Gallery with alt/title?
  85. Add an action based on custom post meta field
  86. How do I add a medium to the WordPress database with my own plugin?
  87. how to auto random increment for post view
  88. custom fields not displaying on wordpress site
  89. WordPress hide post from custom post-type on a single page
  90. Create multiple posts when a custom post is created
  91. How to securely controlling data without keeping it in postmeta?
  92. Why Custom fields description is not working WordPress Version 5.4.2?
  93. Adding Custom Endpoint in WordPress Rest API
  94. General Term for this form Field
  95. How do I change the functionality of an image slider which is part of ACF?
  96. Make custom post types using ACF
  97. Problem Advanced Custom Fields PRO
  98. “Enable Media Replace” plugin does not update serialized object in WPMeta
  99. Custom Field used to allow a Free Story; no longer works
  100. Performance considerations – postmeta table versus new table for custom posts with foreign keys?
Categories plugins Tags attachments, custom-field, plugins, post-meta
why does the add_action(‘the_content’) overwrite my page
Does WP get all post_meta on POST page?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress