Responsive Images

To add to the answer from @cristian.raiber, there is no function in WordPress or php to detect screen sizes, and there will in all probabilty never be such functionality. Php runs server side, which runs before clients side which is browser side. As for php, and for that matter WordPress, I cannot see any future … Read more

Pb with responsive image sizes in WP 4.4

I handle the context like this: function wpse_216001_srcset() { // generate your Srcset here and return } function wpse_216001_sizes() { // generate your sizes attribute here and return } add_filter( ‘wp_calculate_image_sizes’, ‘wpse_216001_sizes’, 10 , 2 ); add_filter( ‘wp_calculate_image_srcset’, ‘wpse_216001_srcset’, 10 , 5); // call one of the standard WP image output functions here remove_filter( ‘wp_calculate_image_sizes’, … Read more

How-to add rewrite rules to point the uploads folder to a subdomain

If you are not willing to filter only image uploads, i.e., all uploaded media will reside in the same folder/subdomain, then there’s a simple configuration solution: go to options-media.php set the Store uploads option to wp-content/uploads set the Full URL option to http://uploads.yourdomain.com create a subdomain making the uploads folder be http://uploads.yourdomain.com

How to get attachment id of background image?

Query for post meta keys _wp_attachment_is_custom_background or _wp_attachment_is_custom_background: function t5_bg_img_id() { if ( ! $bg_img = get_background_image() ) return FALSE; $query = array( ‘post_type’ => ‘attachment’, ‘fields’ => ‘ids’, ‘meta_query’ => array ( array ( ‘key’ => ‘_wp_attachment_is_custom_background’, ‘value’ => get_option( ‘stylesheet’ ), ‘compare’ => ‘==’, ), array ( ‘key’ => ‘_wp_attachment_metadata’, ‘value’ => basename( … Read more

Images all broken after migration and upgrade

I think a quick thumbnail regeneration might be the cure for this. Try using Regenerate Thumbnails or a similar plugin, but backup your uploads directory before proceeding. In order to just disable WP responsive images use this filter. /** * Disable WP 4.4 srcset */ add_filter( ‘wp_calculate_image_srcset’, ‘__return_empty_array’ );

How can I set image sizes and still have responsive images using the srcset attribute?

The srcset attribute is constructed from images that are the same aspect ratio. Create a few of those and you’ll be ok. add_image_size( ‘compare-offer-box’, 400, 300, true); add_image_size( ‘compare-offer-box-2’, 800, 600, true); add_image_size( ‘compare-offer-box-3’, 1200, 900, true); for example. The fourth, boolean, argument tells WP to crop to the exact proportions. To resize without cropping, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)