Title: Incompatible with wp functions &#8211; Plugin overwrite the_post_thumbnail function
Last modified: December 17, 2016

---

# Incompatible with wp functions – Plugin overwrite the_post_thumbnail function

 *  [dimizu](https://wordpress.org/support/users/dimizu/)
 * (@dimizu)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/incompatible-with-wp-functions-plugin-overwrite-the_post_thumbnail-function/)
 * Very great plugin thanks.
 * There is an incompatibility with WordPress standard functions.
 * If your plugin is active, then overwrites the standard the_post_thumbnail function
   of wordpress.
 * When I use this in my template:
    `the_post_thumbnail('my_thumbnail_teaser');`
   the result with your plugin not active is: `<img src="http://localhost/xxxxxx/
   wp-content/uploads/2016/12/xxxxx-550x200.jpg" class="attachment-my_thumbnail_teaser
   size-my_thumbnail_teaser wp-post-image" alt="" width="550" height="200">`
 * But when your pugin is active then the result is:
    `<img src="http://localhost/
   xxxxxx/www/wp-content/uploads/image_carousel_thumbs/xxxxxx-550x200-n1cwcejhdhowie1ywtxrw432srvk5ckrml8l6pf8zo.
   jpg" class="attachment-my_thumbnail_teaser size-my_thumbnail_teaser wp-post-image"
   alt="" width="550" height="200">`
 * Do you have a solution?
    -  This topic was modified 9 years, 5 months ago by [dimizu](https://wordpress.org/support/users/dimizu/).

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

 *  Thread Starter [dimizu](https://wordpress.org/support/users/dimizu/)
 * (@dimizu)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/incompatible-with-wp-functions-plugin-overwrite-the_post_thumbnail-function/#post-8612082)
 * Ok, I answer myself 😉
 * The problem is the filter:
    `add_filter( 'wp_calculate_image_srcset_meta', '__return_null');`
   in the icp-functions.php. This filter strips all image attributes for all images
   in the page, also srcset etc of images that not are in the carousel.
 * My solution:
    a) I have deleted the line with the filter b) then before this 
   line: `$output .= "<div class='carousel-item'>{$image_output}</div>";` I striped
   the code in $image_output with:
 *     ```
       $image_output=stripImageAttributes($image_output,'srcset');
       $image_output=stripImageAttributes($image_output,'sizes');
       ```
   
 * Function stripImageAttributes:
 *     ```
       function stripImageAttributes($html,$stripAttribut)
       {
           // init document
           $doc = new DOMDocument();
           $doc->loadHTML('<!doctype html><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body>' . $html . '</body></html>');
   
           // init xpath
           $xpath = new DOMXPath($doc);
   
           // process images
           $body = $xpath->query('/html/body')->item(0);
   
           foreach ($xpath->query('//img', $body) as $image) {
               $toRemove = null;
   
               foreach ($image->attributes as $attr) {
                   if ($stripAttribut == $attr->name) {
                       $toRemove[] = $attr;
                   }
               }
   
               if ($toRemove) {
                   foreach ($toRemove as $attr) {
                       $image->removeAttribute($attr->name);
                   }
               }
           }
   
           // convert the document back to a HTML string
           $html = '';
           foreach ($body->childNodes as $node) {
               $html .= $doc->saveHTML($node);
           }
   
           return $html;
       }
       ```
   
 * (Function from: [http://stackoverflow.com/questions/38023033/remove-everything-else-from-an-image-link-but-keep-src/38023322](http://stackoverflow.com/questions/38023033/remove-everything-else-from-an-image-link-but-keep-src/38023322))
 * Now works for me.
 * Maybe you can integrate a similar or better solution into the next version.
 * greetings
 *  Plugin Author [GhozyLab](https://wordpress.org/support/users/ghozylab/)
 * (@ghozylab)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/incompatible-with-wp-functions-plugin-overwrite-the_post_thumbnail-function/#post-8805521)
 * Hi [@dimizu](https://wordpress.org/support/users/dimizu/)
 * Thank you very much for your solution, really appreciate it 🙂
    I’m going to 
   have to dig around in the code a bit and apply it in the next release…
 *  [badaboom](https://wordpress.org/support/users/badaboom/)
 * (@badaboom)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/incompatible-with-wp-functions-plugin-overwrite-the_post_thumbnail-function/#post-8851778)
 * pls, fix this bug, i creating the project on wp 4.7.2 and “the_post_thumbnail”
   is broken after enable yoast seo plugin. path to the main thumbnail image replace
   to this sh*t [http://localhost/xxxxxx/www/wp-content/uploads/image_carousel_thumbs/xxxxxx-550×200-n1cwcejhdhowie1ywtxrw432srvk5ckrml8l6pf8zo.jpg](http://localhost/xxxxxx/www/wp-content/uploads/image_carousel_thumbs/xxxxxx-550×200-n1cwcejhdhowie1ywtxrw432srvk5ckrml8l6pf8zo.jpg)
   thx

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

The topic ‘Incompatible with wp functions – Plugin overwrite the_post_thumbnail 
function’ is closed to new replies.

 * ![](https://ps.w.org/image-carousel/assets/icon-256x256.png?rev=1226790)
 * [Image Carousel](https://wordpress.org/plugins/image-carousel/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/image-carousel/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/image-carousel/)
 * [Active Topics](https://wordpress.org/support/plugin/image-carousel/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/image-carousel/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/image-carousel/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [badaboom](https://wordpress.org/support/users/badaboom/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/incompatible-with-wp-functions-plugin-overwrite-the_post_thumbnail-function/#post-8851778)
 * Status: not resolved