{"id":340295,"date":"2026-07-20T11:14:48","date_gmt":"2026-07-20T11:14:48","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/w3tc-webp-helper\/"},"modified":"2026-07-20T11:30:05","modified_gmt":"2026-07-20T11:30:05","slug":"sev-rewrite-free-webp-for-w3tc","status":"publish","type":"plugin","link":"https:\/\/wordpress.org\/plugins\/sev-rewrite-free-webp-for-w3tc\/","author":15085268,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"2.0.0","stable_tag":"2.0.0","tested":"7.0.2","requires":"6.0","requires_php":"8.0","requires_plugins":null,"header_name":"SEV Rewrite-Free WebP for W3TC","header_author":"Heinrich Franz","header_description":"Replaces image URLs in post content with WebP versions when supported by the browser and when W3 Total Cache ImageService has successfully generated a WebP version.","assets_banners_color":"","last_updated":"2026-07-20 11:30:05","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"https:\/\/github.com\/HFranz\/wp-sev-rewrite-free-webp-for-w3tc","header_author_uri":"https:\/\/sevmatic.com","rating":0,"author_block_rating":0,"active_installs":0,"downloads":78,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":{"2.0.0":{"tag":"2.0.0","author":"hfranz","date":"2026-07-20 11:30:05"}},"upgrade_notice":[],"ratings":[],"assets_icons":{"icon.svg":{"filename":"icon.svg","revision":3615496,"resolution":false,"location":"assets","locale":false}},"assets_banners":[],"assets_blueprints":{"blueprint.json":{"filename":"blueprint.json","revision":3616593,"resolution":false,"location":"assets","locale":"","contents":"{\"$schema\":\"https:\\\/\\\/playground.wordpress.net\\\/blueprint-schema.json\",\"siteOptions\":{\"blogname\":\"SEV Rewrite-Free WebP for W3TC Preview\",\"blogdescription\":\"Preview and test the SEV Rewrite-Free WebP for W3TC plugin.\"},\"preferredVersions\":{\"php\":\"latest\",\"wp\":\"latest\"},\"features\":{\"networking\":true},\"landingPage\":\"\\\/\",\"login\":true,\"plugins\":[\"w3-total-cache\",\"sev-rewrite-free-webp-for-w3tc\"],\"steps\":[{\"step\":\"runPHP\",\"code\":\"<?php\\nrequire_once '\\\/wordpress\\\/wp-load.php';\\n\\n$configFile = WP_CONTENT_DIR . '\\\/w3tc-config\\\/master.php';\\n\\nif (!file_exists($configFile)) {\\n    throw new Exception('W3TC master.php missing');\\n}\\n\\n$config = include $configFile;\\n\\nif (!is_array($config)) {\\n    throw new Exception('Invalid W3TC config');\\n}\\n\\n$config['version'] = '2.10.2';\\n$config['common.force_master'] = true;\\n\\n$config['extensions.active'] = [\\n    'imageservice' => 'w3-total-cache\\\/Extension_ImageService_Plugin.php'\\n];\\n\\n$config['extensions.active_frontend'] = [\\n    'imageservice' => '*'\\n];\\n\\n$config['extensions.active_dropin'] = [];\\n\\n$config['extension.imageservice'] = true;\\n\\n$config['imageservice'] = [\\n    'compression' => 'lossy',\\n    'auto' => 'enabled',\\n    'visibility' => 'never',\\n    'webp' => true,\\n    'avif' => true\\n];\\n\\n$config['imageservice.configuration_overloaded'] = true;\\n\\nfile_put_contents(\\n    $configFile,\\n    \\\"<?php exit; ?>\\\" . json_encode(\\n        $config,\\n        JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES\\n    )\\n);\\n\"},{\"step\":\"runPHP\",\"code\":\"<?php\\nrequire_once '\\\/wordpress\\\/wp-load.php';\\n\\nif (function_exists('w3tc_flush_all')) {\\n    w3tc_flush_all();\\n}\\n\\nwp_cache_flush();\\n\"},{\"step\":\"runPHP\",\"code\":\"<?php\\nrequire_once '\\\/wordpress\\\/wp-load.php';\\n\\n$configFile = WP_CONTENT_DIR . '\\\/w3tc-config\\\/master.php';\\n$config = include $configFile;\\n\\n$checks = [\\n    'extension.imageservice' => $config['extension.imageservice'] ?? false,\\n    'webp' => $config['imageservice']['webp'] ?? false,\\n    'avif' => $config['imageservice']['avif'] ?? false,\\n    'auto' => $config['imageservice']['auto'] ?? false\\n];\\n\\nforeach ($checks as $key => $value) {\\n    if (!$value) {\\n        throw new Exception('Missing setting: ' . $key);\\n    }\\n}\\n\"},{\"step\":\"runPHP\",\"code\":\"<?php\\nrequire_once '\\\/wordpress\\\/wp-load.php';\\n\\nrequire_once ABSPATH . 'wp-admin\\\/includes\\\/file.php';\\nrequire_once ABSPATH . 'wp-admin\\\/includes\\\/media.php';\\nrequire_once ABSPATH . 'wp-admin\\\/includes\\\/image.php';\\n\\n$tmp = download_url('https:\\\/\\\/picsum.photos\\\/1200\\\/800.jpg');\\n\\nif (is_wp_error($tmp)) {\\n    throw new Exception($tmp->get_error_message());\\n}\\n\\n$id = media_handle_sideload(\\n    [\\n        'name' => 'sev-webp-test.jpg',\\n        'tmp_name' => $tmp\\n    ],\\n    0\\n);\\n\\nif (is_wp_error($id)) {\\n    throw new Exception($id->get_error_message());\\n}\\n\\nupdate_option('sev_webp_test_attachment_id', $id);\\n\"},{\"step\":\"runPHP\",\"code\":\"<?php\\nrequire_once '\\\/wordpress\\\/wp-load.php';\\n\\nwp_remote_get(\\n    home_url('\\\/wp-cron.php?doing_wp_cron=1')\\n);\\n\"},{\"step\":\"runPHP\",\"code\":\"<?php\\nrequire_once '\\\/wordpress\\\/wp-load.php';\\n\\n\\\/* FINAL STEP: disable W3TC setup wizard *\\\/\\n\\nupdate_site_option(\\n    'w3tc_setupguide_completed',\\n    time()\\n);\\n\\nupdate_option(\\n    'w3tc_setupguide_completed',\\n    time()\\n);\\n\\n$state = get_option('w3tc_state');\\n\\nif (is_string($state)) {\\n    $state = json_decode($state, true);\\n}\\n\\nif (!is_array($state)) {\\n    $state = [];\\n}\\n\\n$state['license.terms'] = 'decline';\\n$state['license.community_terms'] = 'decline';\\n\\nupdate_option(\\n    'w3tc_state',\\n    wp_json_encode($state)\\n);\\n\\n\\\/* remove wizard related cache *\\\/\\ndelete_transient('w3tc.verify_plugins');\\ndelete_site_transient('w3tc.verify_plugins');\\ndelete_option('w3tc_cached_notices');\\n\\nif (function_exists('w3tc_flush_all')) {\\n    w3tc_flush_all();\\n}\\n\\nwp_cache_flush();\\n\"},{\"step\":\"installPlugin\",\"pluginData\":{\"resource\":\"wordpress.org\\\/plugins\",\"slug\":\"sev-rewrite-free-webp-for-w3tc\"},\"options\":{\"activate\":true}}]}"}},"all_blocks":[],"tagged_versions":["2.0.0"],"block_files":[],"assets_screenshots":[],"screenshots":[]},"plugin_section":[],"plugin_tags":[163,187,247,1454,15376],"plugin_category":[50,52,54],"plugin_contributors":[202978],"plugin_business_model":[],"class_list":["post-340295","plugin","type-plugin","status-publish","hentry","plugin_tags-images","plugin_tags-optimization","plugin_tags-performance","plugin_tags-w3-total-cache","plugin_tags-webp","plugin_category-media","plugin_category-performance","plugin_category-security-and-spam-protection","plugin_contributors-hfranz","plugin_committers-hfranz"],"banners":[],"icons":{"svg":"https:\/\/ps.w.org\/sev-rewrite-free-webp-for-w3tc\/assets\/icon.svg?rev=3615496","icon":"https:\/\/ps.w.org\/sev-rewrite-free-webp-for-w3tc\/assets\/icon.svg?rev=3615496","icon_2x":false,"generated":false},"screenshots":[],"raw_content":"<!--section=description-->\n<p>SEV Rewrite-Free WebP for W3TC is a lightweight companion plugin for <a href=\"https:\/\/wordpress.org\/plugins\/w3-total-cache\/\">W3 Total Cache<\/a> that automatically serves WebP images to browsers that support them.<\/p>\n\n<p>Unlike traditional WebP delivery methods, this plugin does <strong>not<\/strong> rely on Apache or Nginx rewrite rules. No changes to <code>.htaccess<\/code>, <code>mod_rewrite<\/code>, or web server configuration are required. Instead, it rewrites image URLs directly in the generated HTML before the page is sent to the visitor.<\/p>\n\n<p>This makes the plugin particularly useful on managed hosting environments, including many Plesk installations, where configuring or relying on web server rewrite rules is difficult, restricted, or simply not practical. If W3 Total Cache ImageService has already generated a WebP version of an image, this plugin serves it without requiring any server-side rewrite configuration.<\/p>\n\n<p>This is an independent, unofficial add-on and is not affiliated with, endorsed by, or sponsored by BoldGrid \/ W3 EDGE, the makers of W3 Total Cache. \"W3 Total Cache\" is a trademark of its respective owner and is used here only to describe compatibility.<\/p>\n\n<p><strong>Features<\/strong><\/p>\n\n<ul>\n<li>No Apache or Nginx rewrite rules required.<\/li>\n<li>No <code>.htaccess<\/code> modifications.<\/li>\n<li>Automatically detects WebP support via the browser's <code>Accept<\/code> header.<\/li>\n<li>Rewrites image URLs only when a corresponding WebP image exists.<\/li>\n<li>Supports <code>src<\/code>, <code>srcset<\/code>, <code>data-src<\/code>, and <code>data-srcset<\/code> attributes.<\/li>\n<li>Sends a <code>Vary: Accept<\/code> header for correct browser, CDN, and proxy caching.<\/li>\n<li>Extends the W3 Total Cache page cache key so WebP and non-WebP pages are cached separately.<\/li>\n<li>Lightweight and requires no configuration.<\/li>\n<\/ul>\n\n<p><strong>How it works<\/strong><\/p>\n\n<ol>\n<li>A visitor requests a page.<\/li>\n<li>The plugin checks the HTTP <code>Accept<\/code> header to determine whether the browser supports WebP.<\/li>\n<li>It scans the post content for image URLs (<code>src<\/code>, <code>srcset<\/code>, <code>data-src<\/code>, and <code>data-srcset<\/code>).<\/li>\n<li>For each image, it checks whether W3 Total Cache ImageService has already generated a WebP version.<\/li>\n<li>If a WebP image exists, the corresponding URL in the generated HTML is replaced with the <code>.webp<\/code> URL.<\/li>\n<li>A <code>Vary: Accept<\/code> response header is added so browsers, CDNs, and reverse proxies cache WebP and non-WebP responses separately.<\/li>\n<li>The W3 Total Cache page cache key is extended with <code>:webp<\/code> or <code>:no-webp<\/code>, ensuring W3 Total Cache stores separate cached pages for browsers with and without WebP support.<\/li>\n<\/ol>\n\n<p><strong>Requirements<\/strong><\/p>\n\n<ul>\n<li>W3 Total Cache must be installed and active.<\/li>\n<li>Images must have been converted using <strong>Media \u2192 W3TC Image Service<\/strong>.<\/li>\n<\/ul>\n\n<p><strong>Limitations<\/strong><\/p>\n\n<p>This plugin <strong>does not convert images<\/strong> to WebP. Image conversion is handled entirely by W3 Total Cache ImageService. If no WebP version exists for an image, the original image URL remains unchanged.<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Upload the <code>sev-rewrite-free-webp-for-w3tc<\/code> folder to the <code>\/wp-content\/plugins\/<\/code> directory.<\/li>\n<li>Activate the plugin through the <strong>Plugins<\/strong> menu in WordPress.<\/li>\n<li>Ensure W3 Total Cache is installed and that images have been converted via W3TC ImageService.<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt id=\"does%20this%20plugin%20convert%20images%20to%20webp%3F\"><h3>Does this plugin convert images to WebP?<\/h3><\/dt>\n<dd><p>No. Image conversion is handled entirely by W3 Total Cache ImageService. This plugin only rewrites image URLs in the generated HTML when a WebP version already exists.<\/p><\/dd>\n<dt id=\"why%20is%20it%20called%20%22rewrite-free%22%3F\"><h3>Why is it called \"Rewrite-Free\"?<\/h3><\/dt>\n<dd><p>Unlike traditional WebP solutions, this plugin does not require Apache or Nginx rewrite rules. No changes to <code>.htaccess<\/code> or web server configuration are needed. Instead, it rewrites image URLs in the generated HTML before the page is sent to the visitor.<\/p><\/dd>\n<dt id=\"does%20it%20work%20with%20multisite%20installations%3F\"><h3>Does it work with multisite installations?<\/h3><\/dt>\n<dd><p>Yes. The plugin supports WordPress multisite installations. Each site automatically uses its own W3 Total Cache ImageService-generated WebP images.<\/p><\/dd>\n<dt id=\"will%20non-webp%20browsers%20be%20affected%3F\"><h3>Will non-WebP browsers be affected?<\/h3><\/dt>\n<dd><p>No. The plugin only rewrites image URLs when the browser's <code>Accept<\/code> header includes <code>image\/webp<\/code>. Other browsers continue to receive the original image formats.<\/p><\/dd>\n<dt id=\"does%20it%20work%20with%20lazy-loading%20plugins%3F\"><h3>Does it work with lazy-loading plugins?<\/h3><\/dt>\n<dd><p>Yes. The plugin replaces URLs in <code>src<\/code>, <code>srcset<\/code>, <code>data-src<\/code>, and <code>data-srcset<\/code> attributes, making it compatible with most lazy-loading solutions.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>2.0.0<\/h4>\n\n<ul>\n<li>Rename plugin to \"SEV Rewrite-Free WebP for W3TC\" to avoid confusion with W3 Total Cache plugin.<\/li>\n<li>Add translation support and German translation.<\/li>\n<\/ul>\n\n<h4>1.0.0<\/h4>\n\n<ul>\n<li>Initial release.<\/li>\n<\/ul>","raw_excerpt":"Replaces image URLs with WebP versions when supported and available through W3 Total Cache ImageService.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/340295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=340295"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/hfranz"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=340295"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=340295"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=340295"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=340295"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=340295"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=340295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}