Images uploading to wrong directory after changing to multisite

Check the value of the ms_files_rewriting option in the site_options table. If ms_files_rewriting is disabled, then WordPress will automatically append /sites/number to that Upload Path value for the subsites. This setting should be disabled by default for any Multisite networks created after WordPress 3.5. It should only be enabled for older networks. If that setting … Read more

Image sizes and order of operations

wp_get_attachment_image_src will always return a URL to a file if the image exists in some size. If the size you ask for doesn’t exist then you get the URL for the full size image as uploaded. (This isn’t the “large” image size.) So, for a valid image ID, your conditional if(wp_get_attachment_image_src($id, array($preferred_size, $preferred_size))) will always … Read more

How to set dimensions of the post thumbnails (featured images)

Add this code to your theme’s functions.php file. Images are resized by WordPress when they are uploaded. A plugin such as Regenerate Thumbnails can be used to ensure that source images have been properly generated if image sizes are changed after the initial upload. // Sets the parameters for the post-thumbnail image size // https://codex.wordpress.org/Function_Reference/set_post_thumbnail_size … Read more

SSL: How to make customizer images Protocol Relative in WordPress?

I think the simpler solution would be to create your own function: function get_theme_mod_img($mod_name){ return str_replace(array(‘http:’, ‘https:’), ”, get_theme_mod($mod_name)); } then just use it: <a href=”https://wordpress.stackexchange.com/questions/256864/<?php echo esc_url(get_theme_mod(“slide_one_link’)); ?>”><img src=”<?php echo esc_url( get_theme_mod_img( ‘slide_img_upload_one’ ) ); ?>” alt=”<?php echo get_theme_mod( ‘slide_title_1’ ); ?>” /></a> there is another solution that involve filters as you can see … Read more

Why is wordpress searching for @2x images?

Despite having no plugins installed through wordpress, I did have retina.min.js being enqueued in my functions.php file from the template I downloaded. Retina.min.js (source: http://imulus.github.io/retinajs/) looks for high resolution versions (denoted with suffix @2x right before the extension) of each image in your site and attempts to replace them if any are found. Since I … Read more

Image file sizes increasing on upload

OK I seem to have found the answer to this. The theme I’m using has Aqua Resizer installed. Quality was set to 100% which for some reason made the resized versions bigger in file size. I’ve changed the quality setting to 80 and it has sorted it.

Passing srcset to image attachment method

I can’t say I’ve tested this but here’s what you could to, it should in theory work. The wp_get_attachment_image() functions 4th parameter is an array of attributes. You should be able to pass what you get returned from wp_get_attachment_image_srcset() to the attribute parameter as follows, sort of similar to the example seen on the docs. … Read more