2.1.1 (2024-09-03)
- Fix bug when Timmy::get_image() is called with null as the attachment parameter (d1d102c)
2.1.0 (2024-08-30)
- Add img_class argument for get_timber_picture_responsive() (#84) (efcf332)
- Remove check for attachment post type that can’t be overridden (#85) (13574be)
2.0.1 (2024-07-30)
- Improve compatibility with Timber v2 (7a2a2b6)
2.0.0 (2024-05-08)
- Remove Timmy::VERSION constant
- Add compatibility with Timber 2.x
1.1.0 (2024-03-26)
- Optimize filter priority for deleting and generating image sizes (2ec4013)
- Add release workflow (#64) (54b4d5e)
- Always export composer.json (142efa9)
- Fix a PHP 8.1 deprecation (cbce1f2)
- Increased minimum supported PHP version to 7.4.
- Increased required Timber version to 1.9.
- Added support for lazy loading with
loading
attribute. - Added
width
andheight
attributes for images by default. - Added support for WebP images.
- Added support for getting Timmy image sizes with
wp_get_attachment_image_src()
. - Added
get_timber_image_alt()
function. - Added
get_timber_image_caption()
function. - Added
get_timber_image_description()
function. - Added
get_timber_picture_responsive()
function. - Added
get_timber_picture_fallback_image()
function. - Added better support for SVG images.
- Fixed a bug when Timmy tried to resize files that it shouldn’t (video files for example).
- Fixed issue when Timmy created upscaled image files even though it shouldn’t.
- Changed oversize configuration option naming from
oversize
toupscale
. You can still useoversize
, but it will be deprecated in the future. - Removed the
title
attribute from the<img>
attributes, which was added by default with an image’s description. That approach was too opinionated and might only make sense in some use cases. If you still want to somehow use the image description, you can use theget_timber_image_description()
function. - Improved hints about controlling image sizes for Yoast.
- Removed deprecated
get_image_attr_html()
,get_timber_image_attr()
andget_acf_image_attr()
functions.
- Added a new
Timmy\Image
class that is used to generate the markup for an image. Most of the functionality that was in theget_timber_*()
functions before now lives in that class. - Added a
Timmy\Timmy::get_image()
function to get aTimmy\Image
in a way that allows developers to extend theTimmy\Image
class.
🚫 Before
new Timmy\Timmy();
✅ After
Timmy\Timmy::init();
🚫 Before
new Timmy\Responsive_Content_Images()
✅ After
Timmy\Timmy::responsive_content_images();
- Changed additional parameters that are passed to the
timber/src_default
filter. There is no longer an array of additional$attributes
to this filter, but only an instance ofTimmy\Image
. - Removed function pluggability. This means that you can’t overwrite any Timber functions anymore. If you want a similar functionality, you can copy the functions. They have way less logic in them than before, because a lot of the logic moved to the
Timmy\Image
class. - Removed
get_post_thumbnail()
andget_post_thumbnail_src()
functions, because they are not namespaced as the other functions and are practically the same asget_timber_image()
andget_timber_image_src()
.
- Added
Timmy\Timmy::VERSION
constant. You can use this to check Timmy’s version usingversion_compare()
:if ( version_compare( Timmy\Timmy::VERSION, '1.0.0', '<' ) ) { // Do something for Timmy versions < 1.0.0. }
- Fixed a bug when Timmy tries to resize files that it shouldn’t, like video files.
- Updated testing suite.
- Update
- Fixed more issues with regex for Responsive Content Images.
- Fixed regex for Responsive Content Images.
- Fixed a bug for attachments that were deleted from the media library.
- Added
content_filters
argument for Responsive Content Images constructor. - Fixed performance when a lot of image data is requested.
- Added Block Editor support for the Responsive Content Images functionality.
- Added new
timber_image_srcset()
function to get only the srcset for an image size. - Added support for using values like
1x
and2x
in the srcset definition. - Fixed
get_timber_image_responsive_acf()
function. - Fixed a bug when
srcset
sizes weren’t generated on upload. - Fixed a bug when the
sizes
was written into the markup even though there was nosrcset
. - Deprecated function
get_acf_image_attr()
.
This release fixes a bug when low-quality image sizes were generated when using WordPress 5.3+.
As of WordPress 5.3, images above 2560px will be scaled down to a smaller version for the full
size of an image. This version will include -scaled
in its filename. Because Timmy relied on wp_get_attachment_url()
, smaller image sizes would be created based on this scaled version, which resulted in a very visible quality loss.
Timmy now uses the new wp_get_original_image_url()
function when needed. There’s also a fallback to wp_get_attachment_url()
for WordPress versions below 5.3.
Wrongly generated images will be regenerated on the fly as soon as you install this update.
Timmy now returns the scaled version of an image, when the full
image size is requested. You can always get the original size of an image when using original
instead of full
as the size.
If you want to disable scaled images, you’ll have to use the big_image_size_threshold
filter:
add_filter( 'big_image_size_threshold', '__return_false' );
- Added new filter for
wp_get_attachment_metadata
that adds a sizes configuration for image sizes that are missing in the image meta data. This should improve compatibility when image data is requested through the WP REST API.
- Added new filter
timmy/use_src_default
to define whether a src attribute should be added as a fallback. - Added new filter
timmy/src_default
to define what the src attribute’s should be. - Added new
lazy_sizes
parameter toget_timber_image_responsive_src()
function. This will allow you to prefix thesizes
attribute withdata-
. - Improved lazy filter by adding a parameter to define which attributes should be prefixed with
data-
. E.g., you can now useimage|get_timber_image_responsive('large')|lazy(['srcset', 'src', 'sizes'])
to prefix thesrcset
, thesrc
and thesizes
attributes withdata-
. - Improved the default src fallback for images with
data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
. This fixes bugs in IE 11.
- Added bailout in
image_downsize
filter when no image size could be found. - Updated the order of the image attributes when using
get_timber_image_responsive()
. - Fixed bug when
full
image size couldn’t be found when usingget_timber_image()
.
- Added docs section about WooCommerce.
- Fixed name of inexistent setting in example in the docs.
- Added testing setup to be able to test Timmy functionality and make it more robust.
- Introduced new function
Helper::get_attribute_html()
that is used to turn an associative array of HTML attributes into a string. Internally, the handling of a list of HTML attributes was improved by introducing attribute arrays that get passed around and will be turned into HTML by this new function. - Introduced new function
get_timber_image_attributes_responsive()
that can be used to get an associative array of default HTML attributes for a responsive Timber image. - Introduced new function
get_timber_image_texts()
that is used to retrieve alt and title attributes for an image. - Deprecated the
get_image_attr_html()
function in favor ofHelper::get_attribute_html
. - Deprecated the
get_timber_image_attr()
function in favor ofget_timber_image_texts()
.
- Introduced arguments array for
Responsive_Content_Images
class with new optionmap_sizes
, that allows the usage of custom image sizes for image sizes used in the content. - Introduced new filter
timmy/responsive_content_image/attributes
to filter image attributes used for a responsive content image. - Introduced new filter
timmy/responsive_content_image
to filter the image HTML markup for a responsive content image. - Added filter that automatically removes any width styles from WordPress-generated
<figure>
tags.
When an image is uploaded, Timmy now generates image metadata that is saved in the database. This improves compatibility with third party plugins that sometimes check this metadata for various reasons. For example, Yoast SEO needs this data to generate the markup for OG image tags.
To generate this data for existing images, you’d have to run Regenerate Thumbnails.
The README file was quite long, probably a little too long. The big part of the documentation can now be found in separate files in the docs/
folder. Use the Documentation Section in the README for an entry point.
- Escaped HTML attributes with
esc_attr()
for better security and to prevent errors when certain characters are used in image alt texts and titles.
- Changed how the bug that was fixed in 0.13.4 is handled. Solve it differently, so that the changes made for the
timmy/resize/ignore
filter in 0.13.4 could be reversed. Check the filter section in the README for how thetimmy/resize/ignore
filter works. Sorry! - Fixed a whitespace bug in
get_timber_image_responsive_src()
that was introduced in 0.13.3 (a17aa2e825c0b0b20e613f70d7aa735711170367).
- Fixed a bug when
timmy/resize/ignore
filter was ignored in the backend when attachments were queried. Changed parameters passed totimmy/resize/ignore
filter. Instead of the$attachment_id
parameter, there’s now a$mime_type
parameter. The order for the following parameters changed as well. Check the filter section in the README.
- Fixed a bug when Timmy tried to convert a PDF to JPEG. Timmy now checks that a file is not a PDF before converting it to JPG.
- Fixed behavior of
oversize
parameter. Prior to this version, images would grow bigger than their original size even ifoversize['allow']
was set tofalse
. - Extended the
oversize
shortcut to also set thestyle_attr
parameter. This means that you can useoversize => true
oroversize => false
to set all parameters directly. This change only has implications for you if you’ve usedoversize => false
in the past. - Added new filter
timmy\oversize
to set the default values for the oversize parameter. Read more about it in the Filters section of the README.
Changed Composer package type from wordpress-plugin
to library
.
With type wordpress-plugin
, the package was installed into a wp-content/plugins
folder, even if you used it in your theme. With type library
, we follow that Timber does, and it’s still possible to define where the package should be installed. And it will not break backwards compatibility, because the default folder will still be the vendors
folder.
In the upcoming versions of Timmy you’ll see filters that allow you to change certain settings more easily. In this version, we introduce 3 new filters. To read more about the filters, there’s a new Filters section of the README. Here’s an overview over what these changes mean for you.
Introduced a new timmy/sizes
filter to define the image sizes used in Timmy. The way to get image sizes through get_image_sizes()
will be deprecated in a future version of Timmy. The reason for is that get_image_sizes()
is quite a generic function name that could lead to conflicts with other plugins.
This means that instead of returning your image configuration from get_image_sizes()
, you’ll use timmy/sizes
:
DON’T USE
function get_image_sizes() {
return array(
// Image configuration
);
}
USE
add_filter( 'timmy/sizes', function() {
return array(
// Image configuration
);
} );
- Introduced a
timmy/resize/ignore
filter to make it possible to ignore resizing of images. This filter allows you to disable the resizing based on various conditions, that you can define yourself based on the values passed to this filter. - Added a default filter to ignore resizing of GIF images by default. If you still want to enable resizing of GIF images, you can disable the filter by adding the following line to
functions.php
of your theme (after you initialized Timmy withnew Timmy\Timmy()
):
remove_filter( 'timmy/resize/ignore', array( 'Timmy\Timmy', 'ignore_gif' ) );
Introduced a new filter timmy/generate_srcset_sizes
that filters whether srcset sizes should be generated when an image is uploaded. By default, Timmy generated sizes defined in srcset
in your image configuration when you uploaded an image in the backend by default. You could disable this by using a generate_srcset_sizes
in your image configuration. This behavior is now changed:
generate_srcset_sizes
will befalse
by default. If you want a size to generate srcset sizes when an image is uploaded, you need to setgenerate_srcset_sizes
for an image size totrue
.- If you want to enable generating srcset sizes for all images sizes, you can use the
timmy/generate_srcset_sizes
filter. - A value for
generate_srcset_sizes
set on an image size in your configuration will always overwrite values set by the filter.
- Added type
wordpress-plugin
tocomposer.json
. This allows you to install Timmy in a folder other thanvendor/mindkomm/timmy
(#11, Thanks, @salaros). Read more about installing a package to a custom path. - Added possibility to use an image size array directly for frontend functions, instead of adding it to the global image configuration array.
Changed how Timmy is initialized. It now works the same as initializing Timber. You need to initialize it manually in functions.php of your theme:
new Timmy\Timmy();
You can add this right after you called new Timber\Timber();
.
This change was required to make the library more compatible with environments like Bedrock, where WordPress might not have been loaded when the Composer package is initialized.
Other changes
- Fixed missing files when Timmy is installed as a plugin.
- Fixed leading whitespace for
srcset
attributes.
- Added support for responsive content images, which means that Timmy can now make images inserted in the post content via the WordPress Editor responsive.
- Optimized image markup by using the
srcset
attribute only if multiple images are available. If an image has only one image in srcset, it falls back to using thesrc
attribute instead. - Added
src
fallback attribute to all responsive images by default to fix invalid markup errors (as recommended by Picturefill). - Optimized performance in the backend.
- Only thumbnails and full sizes of images are shown in the backend to prevent on-the-fly resizing of images (e.g. in the Media Grid).
- Uses full size instead of large size if 'large' is present as a size.
- Fixed selectable images sizes that appear in various positions in the backend.
- Added fallback for GIFs to return full size when image metadata can’t be read.
- Internal: Introduced new helper class for static helper functions.
- Internal: Replaced deprecated filter
get_twig
withtimber/twig
.
- Made Timmy compatible with newest version 1.3.0 of Timber, which is now also the minimum required version.
- Added warning when key "full" is used in image size config.
- Added warning when an image size does not exist in the image configuration.
- Improved how Timmy selects the correct image source internally.
- Improved how SVG and GIF images are handled. See the FAQ section for more information.
- Improved how Timmy handles images it can’t find. Now, it will return
false
for all images it can’t find. This means that it will silently fail without any error messages.
- Fixed compatibility issue with Timber 1.2.2, where Timber returned the thumbnail size of an image instead of the full size.
- Fixed notice that occurred when oversize parameter was not set in image config.
- Fixed
oversize
parameter and updated documentation.
- Fixed an error when Timmy blocked images showing up in the Media Grid view in the backend.
- Optimized function
get_timber_image_responsive_src()
to directly return the image source when the image is an SVG or a GIF.
- Added composer.json to make it possible to load Timmy through Composer.
- Added check for valid and non-empty TimberImage. Frontend functions now return an empty string when no image was found.
- Made sure image arrays (like used in ACF) are also converted to a TimberImage. This way, it doesn’t matter if an image ID or an array is returned by ACF, Timmy will convert it to a TimberImage.
- Changed image configuration option
size
tosizes
to use the attribute name that is also used in the HTML markup. This means you have to update your image configuration. - Added functionality that prevent smaller images from being oversized. In the image configuration, there’s a new option:
oversize
. False per default, it can be set to true to allow images to grow bigger than their uploaded size. Otherwise, Timmy returns only sizes smaller or equal than the uploaded image size and also adds a style attribute "width" or "height", to prevent the image to autogrow in the browser. - Integrated Timmy’s image sizes better into default WordPress functionalities to better support other plugins like Advanced Custom Fields, Admin Columns by codepress and Yoast SEO.
- Improved README with section about image size keys. See README.
- Fixed call to deprecated method.
- Fixed error when
0
was used for the width parameter. - Namespaced all instances of calls to Timber classes. Timber classes are namespaced since Timber v1.0.0.
- Added support for resize values of
0
for the width parameter. In Timber, a user can pass the value 0 as the width parameter. Images will then be resized proportionally based on the height parameter. This now also works in Timmy. (Thanks to @koraysels for pointing this out.)
- Improved examples in README.
- Added support for letterbox and tojpg filters. See README for more information.
- Made sure other plugins are loaded before plugin is initialized