{"id":288486,"date":"2019-05-31T07:54:46","date_gmt":"2019-05-31T14:54:46","guid":{"rendered":"http:\/\/css-tricks.com\/?p=288486"},"modified":"2019-05-31T09:37:44","modified_gmt":"2019-05-31T16:37:44","slug":"reducing-motion-with-the-picture-element","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/reducing-motion-with-the-picture-element\/","title":{"rendered":"Reducing motion with the picture element"},"content":{"rendered":"

Here\u2019s a bonafide CSS\/HTML trick from Brad Frost and Dave Rupert where they use the <picture><\/code> element to switch out a GIF file with an image if the user has reduced motion enabled<\/a>. This is how Brad goes about implementing that:<\/p>\n

<picture>\r\n  <!-- This image will be loaded if the media query is true  -->\r\n  <source srcset=\"no-motion.jpg\" media=\"(prefers-reduced-motion: reduce)\"><\/source>\r\n\r\n  <!--  Otherwise, load this gif -->\r\n  <img srcset=\"animated.gif\" alt=\"brick wall\"\/>\r\n<\/picture><\/code><\/pre>\n

<\/p>\n

How nifty is this? It makes me wonder if there are other ways this image-switching technique can be used besides accessibility and responsive images…<\/p>\n

Also, it\u2019s worth noting that Eric Bailey wrote about the reduced motion media query<\/a> a while back where he digs into its history and various approaches to use it.<\/p>\n","protected":false},"excerpt":{"rendered":"

Here\u2019s a bonafide CSS\/HTML trick from Brad Frost and Dave Rupert where they use the <picture><\/picture> element to switch out a GIF file with an image if the user has reduced motion enabled. This is how Brad goes about implementing that: <picture> <!– This image will be loaded if the media query is true –> […]<\/p>\n","protected":false},"author":223806,"featured_media":288578,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[17],"tags":[466,1644],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2019\/05\/framed-image.png?fit=1200%2C600&ssl=1","jetpack-related-posts":[],"featured_media_src_url":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2019\/05\/framed-image.png?fit=1024%2C512&ssl=1","_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/288486"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/223806"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=288486"}],"version-history":[{"count":10,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/288486\/revisions"}],"predecessor-version":[{"id":288707,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/288486\/revisions\/288707"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/288578"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=288486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=288486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=288486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}