Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

Add custom sizes attribute to post body images. #629

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified fonts/NonBreakingSpaceOverride.woff
100755 → 100644
Empty file.
Empty file modified fonts/NonBreakingSpaceOverride.woff2
100755 → 100644
Empty file.
Empty file modified footer.php
100755 → 100644
Empty file.
Empty file modified functions.php
100755 → 100644
Empty file.
30 changes: 30 additions & 0 deletions inc/template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,36 @@ function twentynineteen_post_thumbnail_sizes_attr( $attr ) {
}
add_filter( 'wp_get_attachment_image_attributes', 'twentynineteen_post_thumbnail_sizes_attr', 10, 1 );

/**
* Add custom sizes attribute to responsive image functionality for post content images.
*
* @origin Twenty Nineteen 1.0
*
* @param string $sizes A source size value for use in a 'sizes' attribute.
* @param array|string $size Requested size. Image size or array of width and height values
* in pixels (in that order).
* @param string|null $image_src The URL to the image file or null.
* @param array|null $image_meta The image meta data as returned by wp_get_attachment_metadata() or null.
* @param int $attachment_id Image attachment ID of the original image or 0.
* @param array $block_attr Attributes from the parent block.
*/
function twentynineteen_calculate_image_sizes_attr( $sizes, $size, $image_src, $image_meta, $attachment_id, $block_attr ) {
if ( is_admin() ) {
return $sizes;
}

$align = $block_attr[align];
if ( '' === $align ) {
$sizes = '(min-width: 768px) calc(8 * (100vw / 12) - 28px), (min-width: 1168) calc(6 * 100vw/12) - 28px), calc(100% - (2 * 1rem))';
} elseif ( 'wide' === $align ) {
$sizes = '(min-width: 768px) 80%, calc(100% - (2 * 1rem))';
} elseif ( 'full' === $align ) {
$sizes = '100vw';
}
return $sizes;
}
add_filter( 'wp_calculate_image_sizes', 'twentynineteen_calculate_image_sizes_attr', 10, 6 );

/**
* Returns the size for avatars used in the theme.
*/
Expand Down
Empty file modified js/touch-keyboard-navigation.js
100755 → 100644
Empty file.
44 changes: 22 additions & 22 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
=== Twenty Nineteen ===
Contributors: the WordPress team
Tags: one-column, flexible-header, accessibility-ready, custom-colors, custom-menu, custom-logo, editor-style, featured-images, footer-widgets, rtl-language-support, sticky-post, theme-options, threaded-comments, translation-ready
Requires at least: 4.9.6
Tested up to: 5.0
Stable tag: 1.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Our 2019 default theme is designed to show off the power of the block editor.

== Description ==
Our 2019 default theme is designed to show off the power of the block editor. It features custom styles for all the default blocks, and is built so that what you see in the editor looks like what you'll see on your website. Twenty Nineteen is designed to be adaptable to a wide range of websites, whether you’re running a photo blog, launching a new business, or supporting a non-profit. Featuring ample whitespace and modern sans-serif headlines paired with classic serif body text, it's built to be beautiful on all screen sizes.

== Changelog ==

= 1.0 =
* Initial Release

== Resources ==
* normalize.css, © 2012-2018 Nicolas Gallagher and Jonathan Neal, MIT
* Underscores, © 2012-2018 Automattic, Inc., GNU GPL v2 or later
=== Twenty Nineteen ===
Contributors: the WordPress team
Tags: one-column, flexible-header, accessibility-ready, custom-colors, custom-menu, custom-logo, editor-style, featured-images, footer-widgets, rtl-language-support, sticky-post, theme-options, threaded-comments, translation-ready
Requires at least: 4.9.6
Tested up to: 5.0
Stable tag: 1.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Our 2019 default theme is designed to show off the power of the block editor.
== Description ==
Our 2019 default theme is designed to show off the power of the block editor. It features custom styles for all the default blocks, and is built so that what you see in the editor looks like what you'll see on your website. Twenty Nineteen is designed to be adaptable to a wide range of websites, whether you’re running a photo blog, launching a new business, or supporting a non-profit. Featuring ample whitespace and modern sans-serif headlines paired with classic serif body text, it's built to be beautiful on all screen sizes.
== Changelog ==
= 1.0 =
* Initial Release
== Resources ==
* normalize.css, © 2012-2018 Nicolas Gallagher and Jonathan Neal, MIT
* Underscores, © 2012-2018 Automattic, Inc., GNU GPL v2 or later
Empty file modified sass/forms/_fields.scss
100755 → 100644
Empty file.
Empty file modified sass/navigation/_menu-footer-navigation.scss
100755 → 100644
Empty file.
Empty file modified sass/navigation/_navigation.scss
100755 → 100644
Empty file.
Empty file modified style-rtl.css
100755 → 100644
Empty file.
Empty file modified style.css
100755 → 100644
Empty file.