You can define a function to remove the protocol and hook it to the attachment URL:
function wpse_79958_remove_protocol_from_attachment($url) {
$url = str_replace(array('http:', 'https:'), '', $url);
return $url;
}
add_filter( 'attachment_link', 'wpse_79958_remove_protocol_from_attachment' );
Also consider to use relative URLs for attachments by using WordPress builtin function wp_make_link_relative
:
add_filter( 'attachment_link', 'wp_make_link_relative' );
Place this code to your functions.php
. Not tested though.
Update: already tested
Related Posts:
- Generated Images sizes do not match Media Settings Image Size
- Find unused images?
- wp_generate_attachment_metadata is creating an empty array
- How to upload WordPress Images to remote web server and display those images in WordPress gallery [closed]
- Redirect to another page using contact form 7? [closed]
- How To Convert External Image URLs To Own Website’s Uploaded Images Automatically?
- wp.media.view.ImageDetails – Save settings as HTML5 data-* attributes for image
- “Add Media” button in custom plugin
- Remote upload file to server B
- What plugin can I use to create a list / slideshow of featured images?
- Upload specific images to specific folder
- Any plugin out there that uses WP’s internal image uploader?
- How to upload image with simple form?
- Resizing all images
- Way to force media uploader use custom image size
- How to create an edit media button for slideshow plugin?
- Use Media Uploader in Plugin
- Upload images from custom plugin using the media modal
- How to upload thousands of images?
- Saving/Writing/Adding file to upload folder
- How do I create a full-bleed background image on text mouseover? [closed]
- How to import 55k images (uploaded via FTP) into WordPress Media libary? [closed]
- Bulk Image Uploader to create new post from each image [closed]
- Adding Attachment Display Settings in custom media frame
- How to upload images to WP Panel keeping correct folder in FTP
- Media upload not working on theme option in WordPress 3.8.1
- How organize uploaded media in WP?
- Plugin or method to delete uploads not in media library?
- Restrict media upload size by format
- Auto move media file to cloud
- Retrieving Meta from Image Attachment
- media page returnig to 404 in rtmedia [closed]
- Bulk Image Upload And Rerrange Functionality
- adding a button to the media uploader
- How to accept images at multiple sizes and aspect ratios and display as standardized image size / ratio?
- Large amount image data transfer
- Scrape a webpage for image and add it to post
- Simple sildeshow/image-upload plugin?
- Offer Download Links for Product Images
- Bulk Image Resize for Media Library, but for ENLARGING instead of Shrinking
- insert og image link in wordpress post
- Is there a way to auto generate poster image for videos
- How to Upload images to a custom folder in upload folder using media uploader
- what functions to use to resize images and create DB metadata for them after/during upload?
- Remove special characters from filenames
- multiple image upload using wp_enqueue_media
- Uploading images to custom table
- Media library and Upload media problem
- Where to store media uploaded by the plugin?
- How to prevent intermediate images from being created but keep the sizes available for selection in the media library?
- Images not showing on homepage after migration [duplicate]
- Upload the images folder with sub-folders directly to server
- stop resize button for wordpress media
- Why does “updated_post_meta” did not fire when uploading media other than image?
- Serving Images from subdomain in wordpress
- Can export gallery but can’t import it Wp all import
- WordPress not showing manually uploaded files in Uploads folder on Media Library
- WordPress Media Library Folders + Custom Linux Server Hosting
- How to hide particular plain text with link from different subscribers
- how to remove share button from image overlay
- How to hide featured images of all posts falling under the same category in wordpress?
- How to upload large media file in chunks, without any plugin?
- Redirect unloggedin users
- Change language on website and change currency with url query
- Optimal image size for wordpress?
- how can I change all wordpress media file url to custom cdn url?
- Copy/paste local images not working in WordPress
- Upload Image with a file URL and show dynamically on Frontend
- How to add height and width to images on a page(using WP Bakery) to improve Google’s CLS score?
- User uploads image as “Featured Image” but WordPress resizes it?
- Profile image does not upload
- Upload PlugIn Button is missing
- Is classical wordpress eidtor a good option for me to include a large table with a large number of images on my webpage?
- Add a parameter at the end of the url and prettify
- WordPress append -1 to the image name
- Enlarge an image slider when click
- Get all image in media Gallery with alt/title?
- cant upload media/pictures to my wordpress site, cant upload anything to my database
- How to copy the all WordPress media items to another custom plugin folder?
- WordPress built-in compression of images? How well does it compare to Photoshop or Shortpixel?
- unable to write to the database while uploading images
- HTTP Error upload ( localhost )
- Access remote SFTP server via WordPress login?
- Optimise wordpress database using SQL after deleting registered images from Media Folder
- Upload error on localhost (at minimum, not yet tested online)
- how to split and upload a theme on wordpress?
- How to create a folder in wordpress that will contain pages?
- Display Multiple Photos as Featured Image when mouse moves on to it post
- Do images in plugins automatically load?
- How to generate expiring URL of the page?
- Which post/page an image is attached to
- I need to register and resize images, safe to delete plugin afterwards?
- Displaying all the images from all of my articles
- Is it possible to pull all featured images from WP database only?
- how to include my homepage and scc in to a plugin
- the content of the uploads folder gets deleted periodically, how to figure out what causes it?
- Product Page loads terribly slow when product gallery images are added
- unsharp thumbnails after uploading image
- Powerpress upload a podcast without creating a post for it
- Updated wordpress missing image upload area