Skip to main content
Agency Program Get 2× more leads and save 50% on hosting. Built for agencies ready to grow. Book a call
Kama Thumbnail icon

Kama Thumbnail

v3.5.1
by Timur Kamaev · 4.7 (15 reviews)

Creates post thumbnails on fly and cache the result. Auto-create of post thumbnails based on: WP post thumbnail OR first img in post content OR attach …

10K+ active installs Updated Mar 22, 2023 Tested to 6.1.7 Requires PHP 7.1
Try Demo Download
Pre-installed Ready in ~10s No card

About Kama Thumbnail

This plugin allows you to easily create post thumbnails on the fly without overloading your server. It is a great alternative to other thumbnail scripts and supports multisite. You can use the plugin functions in your theme or plugin to create and customize your thumbnails.

Screenshots

Kama Thumbnail screenshot

Frequently asked questions

What is Kama Thumbnail?
Kama Thumbnail is a WordPress plugin that creates post thumbnails on the fly and caches the results. It is designed to be a convenient way to create thumbnails without server overload, serving as an alternative to scripts like "thumbnail.php".
How does Kama Thumbnail work?
The plugin takes a post thumbnail image or the first image in post content, resizes it, and caches the result. It also creates a custom field for the post with the URL to the original image.
Is Kama Thumbnail suitable for beginners?
The plugin is primarily for developers, as it requires using one of its functions in a theme or plugin to work after installation. It does not perform any actions automatically upon installation.
Can Kama Thumbnail create thumbnails from external images?
By default, the plugin does not work with external images due to security reasons. However, users can set allowed hosts on the Settings > Media page to enable this functionality.
What are some of the main functions provided by Kama Thumbnail?
Key functions include `kama_thumb_src()` to return a thumbnail URL, `kama_thumb_img()` to return an IMG tag, and `kama_thumb_a_img()` to return an IMG tag wrapped with an `<a>` link to the original image.

Changelog

3.5.1

  • CHG: Options Page Moved from Media page to separate page.
  • CHG: Minor improvements.
  • IMP: Note if ini_get( 'max_execution_time' ) === 0.

3.5.0

  • CHG: !IMPORTANT All core classes moved under Kama_Thumbnail namespace. So if you use such classes as Kama_Thumbnail or Kama_Make_Thumb directly – You need to update your code to use namespase. Example: Kama_Thumbnail_Helpers::parse_main_dom() >>> Kama_ThumbnailHelpers::parse_main_dom() OR new Kama_Make_Thumb() >>> new Kama_ThumbnailMake_Thumb().
  • CHG: CHMOD Options moved: Kama_Make_Thumb::$CHMOD_DIR >>> kthumb_opt()->CHMOD_DIR and Kama_Make_Thumb::$CHMOD_FILE >>> kthumb_opt()->CHMOD_FILE
  • NEW: $src parameter now understand Attachment ID|Attachment Object|WP_Post.
  • NEW: no_photo_url option now supports attachment ID as a value.
  • NEW: Delete cached thumbnails of deleted attachment.
  • IMP: Unit test improvements.
  • IMP: src value moved to srcset and src now contains the original URL.
  • IMP: decoding="async" by default for kama_thumb_img().
  • IMP: Checks the cache_dir path before deleting all files. This is to avoid accidentally deleting files in another directory. Now cache folder must contain one of substring cache or thumb.
  • BUG: Type hint in get_src_from_text() method.
  • BUG: kama_thumb__img_attrs hook support srcset attribute bugfix.
  • BUG: stub need to be created when url with not allowed domain was passed. But the stub was created in the path of the normal image.
  • BUG: Bug fix with symbolic links in WP_PLUGIN_DIR|WPMU_PLUGIN_DIR paths.

3.4.2

  • NEW: Option to delete single IMG cache by image/thumb URL or attachment ID.
  • NEW: CLI command to delete single IMG cache.
  • CHG: IMPORTANT – now requires PHP 7.2 (was 5.6).
  • IMP: Refactoring and improvements.
  • IMP: Unit tests.

3.4.1

  • BUG: Uninstall.php bugfix.

3.4.0

  • NEW: hook: ‘kama_thumbnail__allowed_hosts’.
  • FIX: Bugfixes from last refactor.
  • IMP: Code improvements.
  • IMP: Huge refactor.

3.3.8

  • NEW: hook kama_thumb__replece_in_content_args.
  • NEW: wh parameter – set width & height params at once. Example: kama_thumb_img( 'wh=200:300' ).
  • FIX: PHP 8.0 support.
  • Refactor.

3.3.7

  • FIX: crop parameter fixes.
  • BUG: <a> attributes were passed with prefix a_.
  • IMP: For convenience, to not specify standard attributes in the attr parameter, added support for attributes: data-src, data-srcset (for tag IMG), rel, target, download (for tag A). Also added attributes sizes and “srcset` for IMG tag, for now you can just point them, they are not handled in any way.
  • IMP: Constantly set img $attrs variables to pass them to hooks – it’s more convenient.
  • IMP: The 3rd parameter for hooks kama_thumb__img_attrs, kama_thumb__a_img_attrs is an instance of the class.

3.3.6

  • Minor Bugfix.

3.3.5

  • FIX: Bug about class-Kama_Thumb_CLI.php file

3.3.3

  • FIX: Multisite bug fix.
  • NEW: WP_CLI initial support.

3.3.2

  • huge bug with path when creating thumbs;
  • set_args() refactor;
  • yes_stub parameter become deprecated;
  • fix no_stub parameter;
  • Minor bug fixes.

3.3.1

  • FIX: get_src_from_postmeta() fix notices if GLOBAL $post is not set.

3.3

  • NEW: Parameter force_format.
  • NEW: Force GD lib if Imagick fails thumb creation.

3.2

  • NEW: Filter kama_thumb_file_sub_dir.
  • NEW: loading="lazy" attribute for kama_thumb_img() kama_thumb_a_img()
  • FIX: The same thumb hash (thumb URL) for image URLs which differs only with query parameters.
  • CHG: IMPORTANT! kama_thumb_make_file_name filter arguments list changed.
  • CHG: Refactoring.

3.1.1

  • FIX: Consider that image could contain metadata with HTML ‘<!DOCTYPE’.

3.1

  • FIX: Bug with adding custom query parameter to original image URL. See kthumb in code.

3.0

  • NEW: Option stop_creation_sec that allow to stop thumb creation after specified period of time. It protect from PHP fatal error max execution time when there are too many images to process.
  • FIX: pre_do_thumbnail_src filter has not return any value.

2.9.20

  • FIX: parse_main_dom() regular expression fix for ps.w.org type domain.

2.9.19

  • FIX: parse_main_dom() function regular expression fix and improve of the function logic. New hook kama_thumb_parse_main_dom.
  • FIX: Warning suppression for wp-config.php check – @ file_exists( dirname( ABSPATH ) . wp-config.php )

2.9.18

  • NEW: Action kama_thumb_created allow process created thumbnail, for example, to compress it
  • NEW: Filter kama_thumb_make_file_name – allows change created thumbnail filename.

2.9.17

  • FIX: Поддержка PHP 7.4: $url{0} >>> $url[0]

2.8.16

  • FIX: Исправлен потенциальный жесткий баг, когда происходит рекурсивный вызов генерации картинки. Баг можно поймать, только когда на сервере установлено бесконечное время выполнения скрипта.

2.8.15

  • CHANGE: Убрал необходимость включать WP_DEBUG, чтобы работала опция debug.
  • FIX: Полная обработка ImagickException.

2.8.14

  • NEW: Сообщение что заглушки очищены теперь выводится только админам у которых включен WP_DEBUG.

2.8.13

  • NEW: фильтр pre_do_thumbnail_src.
  • NEW: Обработка SVG – если для создания миниатюры преедана ссылка на SVG файл, эта ссылка просто будет возвращена.

2.8.12

  • NEW: фильтр kama_thumb_src.
  • NEW: параметр stub_url.

2.8.11

  • FIX: Заметка в админке об очистке заглушек теперь показывается только админам.

2.8.10

  • FIX: Баг с нестандартными доменами например: domain.academy.

2.8.9

  • ADD: Хук kama_thumb_default_args.

2.8.8

  • FIX: Проверка строки при получении картинки. Иногда по URL может вернуться HTML код вместо данных картинки.
  • NEW: Авто-определение путей при интеграции плагина в тему или в MU плагины. Теперь для интеграции плагина в тему, плагин можно просто положить в папку темы и подключить в functions.php главный файл плагина.
  • DEL: Удалил фильтр kama_thumb_allow_admin_options_page. Теперь его работа базируется на фильтре kama_thumb_def_options, если он используется, то страница опций плагина автоматически отключается и опции указываются через этот фильтр.

2.8.7

  • FIX: Мелкие правки кода.
  • NEW: для kama_thumb_img() автоматически прописывается alt (бурется у вложения), если указан параметр attach_id.
  • NEW: Фильтр: kama_thumb_def_options – позволяет изменить опции по умолчанию (когда плаг ставиться не как плаг)
  • NEW: Фильтр: kama_thumb_allow_admin_options_page – позволяет отключить страницу опций в админке (когда плаг ставиться не как плаг)
  • NEW: Опция: auto_clear_days – каждые сколько дней очищать кэш

2.8.6

  • BUG: wrong resizing when rise_small option enabled and specified size smaller then the image one is.

2.8.5

  • BUG: on save of any type of post was created empty postmeta ‘photo_URL’, but it must be cleared only if it was exist before.

2.8.4

  • CHG: create_function() replaced with lambda function, in order to support PHP 7.2+

2.8.3

  • NEW: parameter ‘rise_small’. If set to false, when thumbnail will not become bigger if it size (width/height) is smaller than the specified size. Default: true – small thumbnails size increases.

2.8.2

  • IMP: function parse_main_dom() now understand localhosts and IP.

2.8.1

  • FIX: incorrect display on options page starting from WP 4.9.0

2.8.0

  • Bugfix: there was error if pass post object (WP_Post) in ‘post’ parameter…

2.7.9

  • CHG: rename filter start with ‘kmt_’ to ‘kama_thumb_’: ‘kmt_set_args’, ‘kmt_is_allow_host’, ‘kmt_img’, ‘kmt_a_img’ become ‘kama_thumb_set_args’, ‘kama_thumb_is_allow_host’, ‘kama_thumb_img’, ‘kama_thumb_a_img’.
  • minor fixes

2.7.8

  • ADD: hook ‘kama_thumb_inited’.
  • FIX: little logic confuse about trigger_error()

2.7.7

  • ADD: support for multisite – in MU plugin has it’s own options page in network settings menu. Child sites don’t have plugin options – it manages globally from network.
  • ADD: now all files creates in sub folders of main cache folder, to avoid folder overflow. SEO redirect from old location to new.
  • IMP: minor fixes: ‘meta_key’ option insurance. ‘debug’ option works only in WP_DEBUG mode. Code improvements.

2.7.6

  • FIX: if set ‘kama_thumb_a_img(‘w=200″, $src )’ where $src is empty. Plugin was tried generate image of current post, but in this case better to show ‘no_photo’ stub.

2.7.5

  • ADD: new parameters for adding attributes to A tag: ‘a_class’, ‘a_style’, ‘a_attr’ – kama_thumb_a_img('w=200 &a_class=foobar &a_style=display:block; &a_attr=rel="nofollow"').

2.7.3 – 2.7.4

  • ADD: ‘crop’ parameter…
  • ADD: ‘attach_id’ parameter – ID of wordpress attachment image. Also, you can set this parametr by pass attachment ID to ‘src’ parament or in second parametr of plugin functions: kama_thumb_img('h=200', 250) or kama_thumb_img('h=200 &attach_id=250')
  • FIX: ‘class.Kama_Make_Thumb.php’ changes and fixes

2.7.2

  • ADD: ‘style’ parameter for ‘kama_thumb_img()’ and ‘kama_thumb_a_img()’ functions.

2.7.0 – 2.7.1

  • ADD: new function echo kama_thumb('width') – it allows to get real ‘width/height’ of image if width/height is empty. Or if we set ‘notcrop’ parameter and small image side will be resized proportionally and we don’t know the size beforehand.
  • CHG: default no_photo image changed.

2.6.3

  • CHG: confusing option ‘debug’ in class.Kama_Make_Thumb now turn on/off on settings page…
  • ADD: options sanitization on save for protection reasons…

2.6.1

  • NEW: languages dir removed from plugin

2.6.0

  • ADD: ‘yes_stub’ parameter for functions ‘kama_thumb_*()’. Useful when ‘no_stub’ set in option, but in special place we need the stub (no photo image)
  • ADD: New button on options page to clear all cache and delete metafields at once.
  • FIX: bug fix with ‘no_stub’ option. Right after plugin activation it worked incorrectly.

2.5.8

  • FIX: To support URL with HTML entity input src noe decodet with html_entity_decode() – ‘it`s-image.jpg’ > ‘it`s-image.jpg’

2.5.7

  • FIX: Supports to URL without protocols: //site.com/folder/image.png

2.5.6

  • FIX: removed two underscore ‘__’ from all classes methods. Because it reserved by PHP.

2.5.5

  • ADD: WP HTTP API to get IMG from URL.
  • ADD: ‘width’ & ‘height’ attributes for ‘kama_thumb_img()’ function for images with not specified ‘width’ or ‘height’ parameter (uses with ‘notcrop’ attribute)
  • BUG: If set ‘notcrop’ parameter and not set ‘height’ – PHP dies with fatal error…

2.5.4

  • ADD: thumb img in post content: now consider ‘srcset’ attribute if it’s set

2.5.3

  • FIX: regular about ‘mini’ class in IMG tag and now you can change ‘mini’ class

2.5.2

  • FIX: some minor fixes for plugin activation and uninstall

2.5.1

  • ADD: Cyrilic domain support – such URL will wokr ‘http://сайт.рф/img.jpg’.
  • ADD: ‘allow’ parameter from single function call fix – not work correctly.

2.5

  • ADD: New filters for Kama_Make_Thumb class: ‘kmt_set_args’, ‘kmt_is_allow_host’, ‘kmt_img’, ‘kmt_a_img’
  • ADD: Is allow host now checks for only main domain (not subdomain). Ex: now plugin works if you try create thumb of ‘http://site.com/img.png’ from ‘foo.site.com’ host
  • ADD: New parameter ‘allow’ – set allowed hosts for only current function call. Ex: kama_thumb_img(“w=200 &h=200 &allow=any”, ‘http://external-domain.com/img.jpg’ );

2.4.4

  • IMPROVE: Get file from remote domain not work properly if there were redirects…

2.4.3

  • FIX: mini class for IMG in content. Was output error if IMG inside and not inside A tag.

2.4.2

  • CHANGE: Kama_Make_Thumb class::get_src_and_set_postmeta() become publik. In order to just original get img url of post.
  • FIX: search img url in post content not worked with relative url like: “/foo.jpg”, and not worked if img extension “jpeg”;
  • FIX: many times faster &lt;img class="mini"&gt; treatment in post content (regular expression fix);

2.4.1

  • FIX: parsing parametrs if it given as string. ex: “h=250 &notcrop &class=aligncenter” notcrop becomes “notcrop_”

2.4

  • FIX: If place second function parameter $src (img url) – it didn’t work correctly, because stupid mistake.
  • FIX: when use class ‘mini’ in post content and IMG already wrapped with A tag, plugin made double A wrap.
  • IMPROVE: Now self hosted images firstly parses as absolute path, and if there is error, it parses as URL. This method is much stable in some cases.
  • ADD: Place ‘any’ in alowed hostes string on settings page, and plugin will make thumbs from any domain.

2.3

  • Great Bug: Now if parameters passes as string ‘src’ parameter better pass as second argument of functions kama_thumb_*(“w=200 &h=300”, ‘http://site.com/image.jpg’).

2.2

  • ADD: ‘attr’ parameter. Allow to pass any attributes in IMG tag. String passes as it is, without escaping.

2.1

  • ADD: aliases for passed parameters: src = url|link|img, post_id = post (can be passed as post object), q = quality, w = width, h = height
  • FIX: when parameters passes as string and “src” parameter has aditional query args (“src=$src &w=200” where $src = http://site.com/img.jpg?foo&foo2=foo3) it might be confuse, that’s why “src” parameter must passes in the end of string, when parameters passes as string (not array).
  • CHG: some code refactoring in class.Kama_Make_Thumb.php file.
  • FIX: no_stub worked only for images from posts. When ‘src’ is setted parameter ‘no_stub’ had no effect;

2.0

  • ADD: notice message when no image library instaled on server (GD or Imagic)
  • ADD: diferent names for real thumb and nophoto thumb. And possibility to clear only nophoto thumbs from cache. All it needed to correctly create IMGs from external URLs (not selfhosted img) – sometimes it can’t be loaded external imges properly.

1.9.4

  • FIX: ext detection if img URL have querya rgs like *.jpg?foo

1.9.3

  • CHG: DOCUMENT ROOT detection if allow_url_fopen and CURL disabled on server

1.9.2

  • FIX: trys to get image by abs server path, if none of: CURL || allow_url_fopen=on is set on server

1.9.1

  • FIX: getimagesizefromstring() only work in php 5.4+

1.9.0

  • ADD: Images parses from URL with curl first

1.8.0

  • ADD: Images parses from URL. It FIX some bugs, where plugin couldn’t create abs path to img.
  • ADD: Allowed hosts settings. Now you can set sites from which tumbs will be created too.

1.7.2

  • CHG: Back to PHP 5.2 support ?

1.7.1

  • CHG: PHP lower then 5.3 now not supported, because it’s bad practice…

1.7

  • FIX: refactor – separate one class to two: “WP Plugin” & “Thumb Maker”. Now code have better logic!

1.6.5

  • ADD: EN localisation

1.6.4

  • ADD: now cache_folder & no_photo_url detected automatically
  • ADD: notcrop parametr

Try other plugins