Automatically wrap multiple images in div

This is a function I use to add a wrapper to each image. I know it’s not 100% what you want, but I thought this might give you a handle to work from. function add_image_wrapper( $content ) { $content = preg_replace_callback( ‘/<img[^>]+>/im’, function ( $matches ) { $image = $matches[0]; $classes = array(); preg_match( ‘/class=”align([^”]+)”/im’, … Read more

Changing path for media upload folder in wordpress multisite

This has been answered Hook filter to change wp_upload_dir() path in multisite , including code to hook into the upload_dir hook. Note that there is a setting in wp-config.php for the ‘base’ upload folder define(‘UPLOADS’, ‘wp-content/myimages’); So with this code, the uploads folder is wp-content/myimages. But, that changes the place WP looks for the media, … Read more

upload featured image in custom post type from frontend

You are using the wp_insert_attachment() function, which states the following in the Codex: This function is part of the low-level API used by WordPress for handling attachments. To perform the entire attachment upload and insertion process at once, you will want to use media_handle_upload() instead in most cases. So to automatically generate the image resizes … Read more

Host images only on CDN

I’ve never heard of a CDN that replaces your servers storage completely, only mirroring. However, I know (as I’ve done this on multiple installs) you can offload your current and future media library items to AWS S3 with a plugin like Media Cloud. Media items get off of your pricy and limited hosting server, and … Read more

Featured images not displaying at full resolution

Without seeing your theme setup you could try this. If you don’t need that size of image, set the thumbnail size and then regenerate your thumbnails. Keep in mind this will set this size image for all thumbnails, this may not be what you want. Add the following to your functions.php. set_post_thumbnail_size(560, 315); More info … Read more

SVG Featured image not shown in twitter

Twitter has some limitations upon file extensions. I see that you’re passing on some variables within your meta tag. https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/markup.html URL of image to use in the card. Images must be less than 5MB in size. JPG, PNG, WEBP and GIF formats are supported. Only the first frame of an animated GIF will be used. … Read more