Title: replace hqdefault with mqdefault
Last modified: February 20, 2021

---

# replace hqdefault with mqdefault

 *  Resolved [kentgravelle](https://wordpress.org/support/users/kentgravelle/)
 * (@kentgravelle)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/replace-hqdefault-with-mqdefault/)
 * Hi,
    I am caching the thumbnails locally. I’d like to cache and serve the mqdefault.
   jpg instead of the hqdefault.jpg vesion of the youtube thumbnail
 * I have very limited coding experience but I saw another question similar on this
   support form.
    Would this code be correct for replacing the hq with the mq version?
 *     ```
       $mq_origThumbUrl = str_replace('hqdefault.jpg', 'mqdefault.jpg', $origThumbUrl); 
   
       $mq_lyte_match_thumburl = str_replace('hqdefault.jpg', 'mqdefault.jpg', $lyte_match_thumburl );
       ```
   
 * Thanks for your awesome plugin! It has greatly improved my page load speed.
    
   Kent
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Freplace-hqdefault-with-mqdefault%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/replace-hqdefault-with-mqdefault/#post-14078950)
 * afraid there is code missing to make that work kentgravelle, where did you find
   this example?
 *  Thread Starter [kentgravelle](https://wordpress.org/support/users/kentgravelle/)
 * (@kentgravelle)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/replace-hqdefault-with-mqdefault/#post-14078963)
 * I researched the str_replace command to see how the syntax worked. And also read
   on a closed support post here about someone else attempting this change.
 * And here: [https://stackoverflow.com/questions/36701847/php-replace-the-very-last-part-of-a-url](https://stackoverflow.com/questions/36701847/php-replace-the-very-last-part-of-a-url)
    -  This reply was modified 5 years, 3 months ago by [kentgravelle](https://wordpress.org/support/users/kentgravelle/).
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/replace-hqdefault-with-mqdefault/#post-14078980)
 * I see. Well, the problem is that the code you provided needs to be “glued” to
   LYTE somehow, hooking into the API.
 * Something like this might work (but I did not test it, so tread with care);
 *     ```
       add_filter('lyte_match_thumburl','lyte_mq_thumburl');
       function lyte_mq_thumburl($thumb) {
           return return str_replace('hqdefault.jpg', 'mqdefault.jpg', $thumb );;
       }
       ```
   
 * happy hacking! 😉
    frank
 *  Thread Starter [kentgravelle](https://wordpress.org/support/users/kentgravelle/)
 * (@kentgravelle)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/replace-hqdefault-with-mqdefault/#post-14078998)
 * LOL!! 🙂 Thanks!!
    I’ll play with that. Kent
 *  Thread Starter [kentgravelle](https://wordpress.org/support/users/kentgravelle/)
 * (@kentgravelle)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/replace-hqdefault-with-mqdefault/#post-14079288)
 * There was an extra `return` that I removed and it worked on the thumbnails in
   the body of the page. The widget thumbs on the sidebar remained as hqdefault.
   jpg
 * However, the page load time did not improve to any significant amount on my tests
   so I removed the code.
 * Thanks again!
    Kent
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/replace-hqdefault-with-mqdefault/#post-14079727)
 * You’re welcome, feel free to [leave a review of the plugin and support here](https://wordpress.org/support/plugin/wp-youtube-lyte/reviews/#new-post)!
   🙂

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘replace hqdefault with mqdefault’ is closed to new replies.

 * ![](https://ps.w.org/wp-youtube-lyte/assets/icon-128x128.png?rev=1836005)
 * [WP YouTube Lyte](https://wordpress.org/plugins/wp-youtube-lyte/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-youtube-lyte/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-youtube-lyte/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-youtube-lyte/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-youtube-lyte/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-youtube-lyte/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * Last activity: [5 years, 3 months ago](https://wordpress.org/support/topic/replace-hqdefault-with-mqdefault/#post-14079727)
 * Status: resolved