Change function in responsive theme

WordPress has a function called wp_is_mobile. It does very simple User Agent checking, which isn’t very reliable. There are a lot of user agents out there and they can easily be falsified. There is no guarantee that a browser representing itself as some user agent actually is that user agent. You can do more complicated … Read more

Benefits of storing uploads in an assets folder?

The only directory a theme or a plugin should write to is the uploads directory. That is the only directory with guaranteed write access (besides the server’s temporary directory). Anything else is wrong and might not work. There is no practical difference between both, except one: the upload directory may be on another (sub) domain … Read more

How can I serve different images depending on screen size with wordpress

add_image_size does change the actual size of the image file. What I hava tried: function odevice_image_sizes() { add_image_size( ‘iphone-size’, 300, 100, true );//OF course the dimensions are not correct… add_image_size( ‘tablet-size’, 600, 300, true ); } function show_odevice_at_img_select($sizes) { $sizes[‘iphone-size’] = __( ‘Image size for iphone’ ); $sizes[‘tablet-size’] = __( ‘image size for tablet’ ); … Read more

How to oEmbed from custom field, responsive to container size and responsive

I completed the task with fitvids.js by using the plugin FitVids for WordPress. Chris Coyier describes the integration with WordPress in his screencast Integrating FitVids.js into WordPress (on YouTube). My custom field name is video_url. I used the following code in my template: <?php if (!((get_post_meta($post->ID, ‘video_url’, TRUE))==”)) { echo wp_oembed_get( get_post_meta($post->ID, “video_url”, true) ); … Read more

How to use the responsive images feature from WP 4.4 in your themes

Following our exchange in the comments I’ve reread your question and have a pretty straightforward answer: It looks like it’s working fine. You are worried about the sizes attribute in your second example, but it’s the srcset attribute that you should look at and it is showing all of your image sizes: <img src=”http://xxx.dev/wp-content/uploads/Delft_IMG_6275-e1453192498922.jpg” class=”attachment-full … Read more

WP 4.4 aspect ratio with responsive image

You shouldn’t. srcset is used for when you want to optimise the quality for different devices by serving different sizes of the same image. If you want to serve different crops, you should be using the picture element instead. For example, if the intention of your image sizes is to serve a ‘small’ version to … Read more