{"id":10735,"date":"2025-12-01T16:30:14","date_gmt":"2025-12-01T22:30:14","guid":{"rendered":"https:\/\/infiniteuploads.com\/?post_type=docs&#038;p=10735"},"modified":"2025-12-01T16:39:41","modified_gmt":"2025-12-01T22:39:41","password":"","slug":"checking-whether-a-file-is-offloaded-with-iinfinite_uploads_check_offloaded","status":"publish","type":"docs","link":"https:\/\/infiniteuploads.com\/docs\/developers\/checking-whether-a-file-is-offloaded-with-iinfinite_uploads_check_offloaded\/","title":{"rendered":"Checking Whether a File Is Offloaded with infinite_uploads_check_offloaded"},"content":{"rendered":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<html><body><p>Infinite Uploads provides a filter that allows developers to determine whether a given URL has been offloaded to Infinite Uploads storage. This is especially useful for plugins that need to know if media is being served locally or from the Infinite Uploads cloud&mdash;such as image optimization plugins like ShortPixel.<\/p>\n\n\n\n<p>The filter <strong><code>infinite_uploads_check_offloaded<\/code><\/strong> receives a file URL and returns a boolean value indicating whether Infinite Uploads considers that URL &ldquo;offloaded.&rdquo;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"usage\">Usage<\/h2>\n\n\n\n<p>You can use this filter anywhere in WordPress where you have access to a media URL. Simply call the filter with <code>apply_filters()<\/code> and pass the URL you want to check.<\/p>\n\n\n\n<div class=\"betterdocs-code-snippet-wrapper theme-light betterdocs-code-snippet-7dd106d4\" id=\"betterdocs-code-snippet-7dd106d4\" data-language=\"php\" data-copy-button=\"true\">\n\n            <div class=\"betterdocs-code-snippet-header betterdocs-file-preview-header\">\n        <div class=\"betterdocs-file-preview-left\">\n                            <div class=\"betterdocs-traffic-lights\">\n                    <span class=\"traffic-light traffic-light-red\"><\/span>\n                    <span class=\"traffic-light traffic-light-yellow\"><\/span>\n                    <span class=\"traffic-light traffic-light-green\"><\/span>\n                <\/div>\n            \n            <div class=\"betterdocs-file-info\">\n                                    <div class=\"betterdocs-file-icon\">\n                                                    <span class=\"betterdocs-file-icon-emoji\">&#128024;<\/span>\n                                            <\/div>\n                \n                            <\/div>\n        <\/div>\n\n        <div class=\"betterdocs-file-preview-right\">\n                            <div class=\"betterdocs-code-snippet-copy-container\">\n                    <button class=\"betterdocs-code-snippet-copy-button\" type=\"button\" data-clipboard-target=\"#betterdocs-code-snippet-7dd106d4 .betterdocs-code-snippet-code code\" aria-label=\"Copy code to clipboard\">\n                        <svg width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                            <path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1ZM19 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H19C20.1 23 21 22.1 21 21V7C21 5.9 20.1 5 19 5ZM19 21H8V7H19V21Z\" fill=\"currentColor\"><\/path>\n                        <\/svg>\n                    <\/button>\n                                    <\/div>\n                    <\/div>\n        <\/div>\n    \n    <div class=\"betterdocs-code-snippet-content\">\n        \n        <pre class=\"betterdocs-code-snippet-code language-php\"><code>$is_offloaded = apply_filters( 'infinite_uploads_check_offloaded', $url );\n\nif ( $is_offloaded ) {\n    \/\/ The file is offloaded to Infinite Uploads.\n} else {\n    \/\/ The file is stored locally.\n}\n<\/code><\/pre>\n    <\/div>\n<\/div>\n\n<script type=\"text\/javascript\">\ndocument.addEventListener('DOMContentLoaded', function() {\n    \/\/ Initialize copy functionality for this specific snippet\n    const snippet = document.getElementById('betterdocs-code-snippet-7dd106d4');\n    if (snippet && window.BetterDocsCodeSnippet) {\n        window.BetterDocsCodeSnippet.initCopyButton(snippet);\n    }\n});\n<\/script>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"parameters\">Parameters<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$url<\/code><\/td><td>string<\/td><td>The full URL of the file you want to check.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"return-value\">Return Value<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>bool<\/code><\/td><td><code>true<\/code> if the file is offloaded to Infinite Uploads; <code>false<\/code> if the file is local or not recognized.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-logging-offload-status-for-debugging\">Example: Logging Offload Status for Debugging<\/h3>\n\n\n\n<div class=\"betterdocs-code-snippet-wrapper theme-light betterdocs-code-snippet-74f85a41\" id=\"betterdocs-code-snippet-74f85a41\" data-language=\"php\" data-copy-button=\"true\">\n\n            <div class=\"betterdocs-code-snippet-header betterdocs-file-preview-header\">\n        <div class=\"betterdocs-file-preview-left\">\n                            <div class=\"betterdocs-traffic-lights\">\n                    <span class=\"traffic-light traffic-light-red\"><\/span>\n                    <span class=\"traffic-light traffic-light-yellow\"><\/span>\n                    <span class=\"traffic-light traffic-light-green\"><\/span>\n                <\/div>\n            \n            <div class=\"betterdocs-file-info\">\n                                    <div class=\"betterdocs-file-icon\">\n                                                    <span class=\"betterdocs-file-icon-emoji\">&#128024;<\/span>\n                                            <\/div>\n                \n                            <\/div>\n        <\/div>\n\n        <div class=\"betterdocs-file-preview-right\">\n                            <div class=\"betterdocs-code-snippet-copy-container\">\n                    <button class=\"betterdocs-code-snippet-copy-button\" type=\"button\" data-clipboard-target=\"#betterdocs-code-snippet-74f85a41 .betterdocs-code-snippet-code code\" aria-label=\"Copy code to clipboard\">\n                        <svg width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                            <path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1ZM19 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H19C20.1 23 21 22.1 21 21V7C21 5.9 20.1 5 19 5ZM19 21H8V7H19V21Z\" fill=\"currentColor\"><\/path>\n                        <\/svg>\n                    <\/button>\n                                    <\/div>\n                    <\/div>\n        <\/div>\n    \n    <div class=\"betterdocs-code-snippet-content\">\n        \n        <pre class=\"betterdocs-code-snippet-code language-php\"><code>$url = wp_get_attachment_url( 123 );\n\n$is_offloaded = apply_filters( 'infinite_uploads_check_offloaded', $url );\n\nerror_log(\n    sprintf(\n        'File %s is %s',\n        $url,\n        $is_offloaded ? 'offloaded' : 'local'\n    )\n);\n<\/code><\/pre>\n    <\/div>\n<\/div>\n\n<script type=\"text\/javascript\">\ndocument.addEventListener('DOMContentLoaded', function() {\n    \/\/ Initialize copy functionality for this specific snippet\n    const snippet = document.getElementById('betterdocs-code-snippet-74f85a41');\n    if (snippet && window.BetterDocsCodeSnippet) {\n        window.BetterDocsCodeSnippet.initCopyButton(snippet);\n    }\n});\n<\/script>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"when-to-use-this-filter\">When to Use This Filter<\/h2>\n\n\n\n<p>Use <code>iinfinite_uploads_check_offloaded<\/code> whenever your plugin or integration needs to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Detect whether a media asset is stored in Infinite Uploads cloud storage<\/li>\n\n\n\n<li>Adjust UI or processing logic based on storage location<\/li>\n\n\n\n<li>Prevent duplicate optimization, syncing, or transformation of already-offloaded media<\/li>\n\n\n\n<li>Integrate deeply with Infinite Uploads&rsquo; file management system<\/li>\n<\/ul>\n\n\n\n<p>This hook is part of the latest integration improvements built for compatibility with ShortPixel and other optimization tools.<\/p>\n<\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>Infinite Uploads provides a filter that allows developers to determine whether a given URL has been offloaded to Infinite Uploads storage. This is especially useful for plugins that need to know if media is being served locally or from the Infinite Uploads cloud&mdash;such as image optimization plugins like ShortPixel. The filter infinite_uploads_check_offloaded receives a file [&hellip;]<\/p>\n","protected":false},"author":3787,"featured_media":10762,"template":"","meta":{"_acf_changed":false,"wds_primary_doc_category":0,"wds_primary_doc_tag":0,"footnotes":""},"doc_category":[147],"doc_tag":[],"class_list":["post-10735","docs","type-docs","status-publish","has-post-thumbnail","hentry","doc_category-developers"],"acf":[],"year_month":"2026-04","word_count":216,"total_views":"276","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"Blake Whittle","author_nicename":"blakew","author_url":"https:\/\/infiniteuploads.com\/blog\/author\/blakew\/"},"doc_category_info":[{"term_name":"Developers","term_url":"https:\/\/infiniteuploads.com\/docs-category\/developers\/"}],"doc_tag_info":[],"knowledge_base_info":[],"knowledge_base_slug":[],"_links":{"self":[{"href":"https:\/\/infiniteuploads.com\/api\/wp\/v2\/docs\/10735","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/infiniteuploads.com\/api\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/infiniteuploads.com\/api\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/infiniteuploads.com\/api\/wp\/v2\/users\/3787"}],"version-history":[{"count":0,"href":"https:\/\/infiniteuploads.com\/api\/wp\/v2\/docs\/10735\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/infiniteuploads.com\/api\/wp\/v2\/media\/10762"}],"wp:attachment":[{"href":"https:\/\/infiniteuploads.com\/api\/wp\/v2\/media?parent=10735"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/infiniteuploads.com\/api\/wp\/v2\/doc_category?post=10735"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/infiniteuploads.com\/api\/wp\/v2\/doc_tag?post=10735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}