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 replace URL protocol using PHP?

Simply use set_url_scheme() function.

$share_image_src = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' );
$share_image_src = set_url_scheme( $share_image_src, 'http' );

Related Posts:

  1. How do I change/modify the_post_thumbnail(); html output?
  2. What’s the best way to use the Featured Image for responsive web design?
  3. PHP/Manual use of images? – 2 Questions
  4. Adding Featured Image to Post programatically
  5. How to upload imagick resource to media in wordpress
  6. How to add a featured image to a existing post via php?
  7. How to use SRCSET with get_the_post_thumbnail()?
  8. Adding featured image via PHP
  9. WordPress loop specific thumbnail size
  10. How do I get images (with a thumbnail preview) to show in search results?
  11. fallback image for featured image
  12. How to get Poster (thumbnail) Image of Video
  13. WP Insert Post function – Insert Post Thumbnail
  14. Display All Post Attachments and Assign Class to the Last Image?
  15. How to make thumbnail image fit into a div where image dimentions are completely different?
  16. Assign a picture URL to a page via PHP
  17. How to scale image with equal width and height without distortion?
  18. Featured image fallback link to permalink
  19. is it possible to force wordpress to always save thumbnails as ‘jpg’ not ‘png’
  20. How to Display Image Meta underneath EVERY image in EVERY post
  21. How can I show the post thumbnail from the most recent of a certain post type, in widget?
  22. How can I add pagination and how can I change thumbnail size?
  23. Echo URL of large version of Featured Image
  24. How to stop featured image thumbnail [set as background image] on blog index page just repeating same image across all posts
  25. Trying to add attribute to my posts’ featured image
  26. Recent posts with featured image or fallback image with permalink
  27. Randomly Assign an Image’s Alt Text Based on Data From Post
  28. WP dynamic featured image – Can’t get second featured image url
  29. Set the background to a default image if there isn’t a specified “featured image”
  30. PHP variable = get_the_post_thumbnail_url outputting without slashes
  31. Is it possible to use Data URI image to set a post thumbnail?
  32. WP Post-Thumbnail
  33. Display custom post type title as text if post thumbnail is not available
  34. post thumbnail, conditions, else wont work
  35. ‘Post-thumbnails’ feature does not seem to register
  36. height should be set to auto to avoid pixelation in the post thumbnail function
  37. Three Questions with Twenty Eleven theme
  38. Display related posts without a plugin
  39. WordPress function and string as variable?
  40. Resize image to specific dimension (X to Y ratio)
  41. Apply class to every third list item? [duplicate]
  42. Automatically add images to a menu
  43. Using featured image of blog archive page
  44. if custom field doesn’t exist, use post thumbnail instead, as image background
  45. Help Fallback (thumbnail)
  46. Get featured image with custom size outside WordPress
  47. How to add post thumbnail dynamically using Jquery?
  48. Else/If Statement to Display Photo Descriptions
  49. How to set a featured image (thumbnail) with PHP?
  50. How to change thumbnail src attribute?
  51. Error display post thumbnails for previous and next post
  52. Get the featured image url of clicked post
  53. Fallback image URL if no featured image exists via a shortcode function
  54. Call featured image url
  55. How to pick “full/thumbnail” images in the loop?
  56. Generate responsive post thumbnails of same size
  57. How to Make Thumbnail of Post Stay Animated
  58. Get the alt text of the image in a array
  59. Trying to change featured image from 180×180 to full width on home page
  60. Show different size featured images (the_post_thumbnail) for 1st, 2nd and 3rd posts?
  61. Need to add a post’s featured image to a section on the frontpage
  62. I can’t set image ad fatured programatically
  63. Add Featured Image to Existing Post
  64. wp_query – Exclude the first thumbnail from lazy loading on archives
  65. not outputting medium size image URL
  66. Replace background image with post thumbnail in shortcode
  67. Resize post thumbnail
  68. How to put 2 php codes in functions.php without site crashing
  69. How to add WordPress Featured image in tag ..?
  70. WordPress generate images size after upload
  71. Add a default style if no Featured image is selected
  72. How to link all featured images to custom url in single.php for only non-logged-in users?
  73. How to programmatically set existing image in media library the featured image for a post in wordpress
  74. Having trouble with customizing blog posts on the home page
  75. How to link featured images in single.php for only non-logged-in users?
  76. Thumbnail wouldn’t scale to size properly
  77. get_post_thumbnail_id returns a negative number
  78. Basic PHP question (displaying post title over thumbnail) [closed]
  79. Showing featured image of page’s child’s children page
  80. insert thumbnail image from php script
  81. Can’t put a hyperlink on Featured Post’s Image
  82. add class to background image
  83. News and Featured image
  84. How to correctly add the featured immage (thumbnails) support in a WP theme? Why I can’t add a featured immage?
  85. Overwriting a Shortcode
  86. featured post as div background
  87. How to display thumbnail if post is assigned one otherwise not
  88. Post Thumbnail on Single (if elseif else)
  89. the_post_thumbnail unless video id is added
  90. Setting post thumbnail sizes in template file and functions.php
  91. Facebook share button only share the_permalink(), without thumbnail, tilte, excerpt, etc
  92. How can i give a download link to the thumbnail or featured image
  93. add if statement to the featured image
  94. How to crop featured image in different sizes?
  95. Remove default Image Sizes
  96. Add attribute to featured image with filter (wp_get_attachment_image_attributes)
  97. Generate and upload screenshot as featured image for user-submitted post
  98. Restricting Image Upload Sizes using ‘wp_handle_upload_prefilter’ – Stuck media progress bar when Featured Image?
  99. Nested “do” and “add” Actions is possible?
  100. Can’t access site after making changes to the functions.php [closed]
Categories PHP Tags php, post-thumbnails, social-sharing
Pass important values server-side when processing form
Top level menu position overwrites another entry

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