{"id":15661156,"url":"https://github.com/mitogh/katana","last_synced_at":"2025-05-05T21:33:52.855Z","repository":{"id":57017706,"uuid":"44286369","full_name":"mitogh/Katana","owner":"mitogh","description":":hocho: WordPress - Adjust images sizes on specific posts, post types, pages or page templates.","archived":false,"fork":false,"pushed_at":"2016-03-27T16:06:00.000Z","size":167,"stargazers_count":19,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-22T01:39:14.074Z","etag":null,"topics":["composer","php","wordpress","wordpress-images"],"latest_commit_sha":null,"homepage":"https://github.com/mitogh/Katana","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitogh.png","metadata":{"files":{"readme":"readme-1.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-15T01:30:09.000Z","updated_at":"2023-04-25T10:28:55.000Z","dependencies_parsed_at":"2022-08-22T11:31:18.530Z","dependency_job_id":null,"html_url":"https://github.com/mitogh/Katana","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitogh%2FKatana","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitogh%2FKatana/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitogh%2FKatana/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitogh%2FKatana/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitogh","download_url":"https://codeload.github.com/mitogh/Katana/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252580132,"owners_count":21771269,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer","php","wordpress","wordpress-images"],"created_at":"2024-10-03T13:26:11.719Z","updated_at":"2025-05-05T21:33:52.798Z","avatar_url":"https://github.com/mitogh.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Katana [![Build Status](https://travis-ci.org/mitogh/Katana.svg?branch=master)](https://travis-ci.org/mitogh/Katana)\n\n\u003e Save disk space and creates custom images sizes only where is\nrequired.\n\nCustom filters to allow easy update of images sizes for [Wordpress](https://wordpress.org/).\n\n![](/media/samurai.jpg)  \n***Picture from [WikiImages](https://pixabay.com/samurai-guerrero-caza-de-samurai-67662/)***\n\n# Version 1.1.3 and below only\n\n## Installation \n\n**This is not a plugin**, you can just download the `class-katana.php`\nor use composer to add it as a dependency in your website or plugin.\nAfter you download the file make sure to include the file using `include` function.\n\nIn order to have access to the filters you need to create a new instance\nof the Kata object.\n\n```php\n$katana = new Katana();\n```\n\nAlso makes sure to inclode the file `class-katana.php` into your\n`functions.php` file or in your plugin directory. After that you \ncan add all your custom filters that you may require.\n\n## Usage\n\nThis library comes with custom filters that allows edit what sizes are\ngenerated under some custom post types or under a specific `post_id`. \n\n**Note:** The default size of the image is always generated no matter\nif you remove all sizes.  \n\n## Filters \n\nEach filter allow to return what sizes of images are needed for that\nparticular filter, the returned sizes represents the allowed images\nsizes, each size is the name that was registered when you created an\nimage size using `add_image_size`.\n\n### katana_refine_{post_type}  \n\n`{post_type}`, can be any post type declared on the site, post page or\neven a custom one, like movies.\n\nThis filter allows to refine the sizes of images for a certain post\ntype.\n\n**Example**\n\nThis example remove all the sizes from all of the pages, so any time you\nadd an image on a page it wont create any new size of image. \n\n```php\nadd_filter('katana_refine_page', 'remove_all_sizes_from_pages');\n\nfunction remove_all_sizes_from_pages( $sizes ){\n  // Clear all the sizes of images\n  $sizes = array();\n  return $sizes;\n}\n```\n\n### katana_refine_{post_id}\n\n`{post_id}`, is the id of the post, page or custom post type all new\nentries has a `post_id`\n\nThis filter allow you to change the required sizes on a particular\npost_id all posts, pages or custom post types has a post_id than can be\nused for this. \n\n**Example**\n\nImagine we have previously declared an `author_profile_image` size of\nimage, like:\n\n```php\nadd_image_size( 'author_profile_image', 350, 350, true );\n```\n\nWe need to creates images of the `author_profile_image` size only in the\nentry with the id: `105`.\n\n```php\nadd_filter('katana_refine_105', 'allow_only_author_profile_image');\n\nfunction allow_only_author_profile_image( $sizes ){\n  $sizes = array( 'author_profile_image' );\n  return $sizes; \n}\n```\n\n### katana_refine_{template_slug}\n\n`{template_slug}`,  is the slug of the template, the slug is where is\nlocated the template, replacing `-` and `/` by `_` and witout the `.php`\nextension. \n\n**Examples**  \n\n| Location                    |     Filter name             |\n|-----------------------------|-----------------------------| \n| page-templates/full.php     |     page_templates_full     |\n| page-templates/shop.php     |     page_templates_shop     |\n| portfolio.php               |     portfolio               |\n\n**Example** \n\nThis filter just allow to create two sizes of images in the\n`page-template/full.php`: \n\n- poster\n- landscape\n\n```php\nadd_filter('katana_refine_page_templates_full', 'image_sizes_for_full_page_template');\n\nfunction image_sizes_for_full_page_template( $sizes ){\n  $sizes = array( 'poster', 'landscape' );\n  return $sizes; \n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitogh%2Fkatana","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitogh%2Fkatana","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitogh%2Fkatana/lists"}