-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add featured images to Latest Posts block #17151
Add featured images to Latest Posts block #17151
Conversation
Thanks for working on this Kelly! Similar to: #16448 |
Hi @ryelle |
Hello! I could really use this feature for an upcoming project and would love to help take it over the line. I'm not familiar with the WP codebase but it looks like there is a panel in the Wordpress admin panel that allows you to modify the image dimensions for the base dimensions (thumbnail, small, medium, etc) so we should be able to pull those values from a config somewhere. |
Hey Steven @stevenbuccini If you need another option then you can take a look at https://wordpress.org/plugins/post-type-archive-mapping/ I use it on a lot of sites. The Gutenberg core Latest Posts Block is still missing a lot of useful features before I can consider using it. If your able to figure out a way to add the featured image to the block that would be very helpful. Either by taking over this PR or adding a new PR. |
import SelectControl from '../select-control'; | ||
import TextControl from '../text-control'; | ||
|
||
class ImageSizeControl extends Component { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We didn't figure out yet a good place for all these block specific components, I don't think "components" is the best place for it as it's more the design system, maybe in block-editor module. We could consider making it priivate as a start in the block-library package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there was discussion here #17148 about where this component should live, but it didn't really come to a conclusion. block-editor
works for me, so I can move that PR ahead which can then move this one out of draft status :)
Hey @ryelle and @youknowriad, any further progress on this PR? |
Just noting that for WordCamp Europe we are using this block and would love to have the featured images working. Be great to test it out there too. |
d929be2
to
a2acabe
Compare
Looking forward to this! Thanks for working on it everyone. Hope to see it live soon. |
a2acabe
to
c785f73
Compare
Yep, I just added this to the WP 5.4 project board. Do you think this is possible, @ryelle? |
@mapk Great! I worked on this yesterday & got it to a reviewable state, so I moved it over to the "Needs Review" column on the board. |
// @todo This should be retrieved dynamically, or from site settings, since it can be changed by the site owner. | ||
function getImageDimensionsFromSlug( slug = 'thumbnail' ) { | ||
switch ( slug ) { | ||
case 'large': | ||
return [ 1024, 1024 ]; | ||
case 'medium': | ||
return [ 300, 300 ]; | ||
case 'thumbnail': | ||
default: | ||
return [ 150, 150 ]; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should do that before landing this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been long enough since I worked on this that I didn't realize this was left in 🤦♀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the real functionality here, but it required adding a new setting imageDimensions
to get the mapping of size name to height & width. I also had to pull "full" out of the available options, since we can't actually get a default height & width of all full size images. Maybe a future iteration of this (or of ImageSizeControl
) could handle this case.
100b40e
to
ca3805b
Compare
The required core changes are being done in https://core.trac.wordpress.org/attachment/ticket/49389/. |
ca3805b
to
7a69fe9
Compare
Yahhh! It has been merged..:) |
height: auto; | ||
width: auto; | ||
} | ||
&.alignleft { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The alignleft
and alignright
classes are intended to be used with CSS float styles (and they probably shouldn't be called alignleft
and alignright
, but that's a whole other topic). This class style override is inconsistent with the usage of the class name elsewhere.
So happy to see this in! 🎉 Thanks everyone! |
This commit includes in the core settings for the gradients theme API stabilized in WordPress/gutenberg#20107, and for the image sizes required for the latest posts feature image WordPress/gutenberg#17151. Props: youknowriad, ryelle. Fixes #49389. git-svn-id: https://develop.svn.wordpress.org/trunk@47240 602fd350-edb4-49c9-b593-d223f7449a82
This commit includes in the core settings for the gradients theme API stabilized in WordPress/gutenberg#20107, and for the image sizes required for the latest posts feature image WordPress/gutenberg#17151. Props: youknowriad, ryelle. Fixes #49389. git-svn-id: https://develop.svn.wordpress.org/trunk@47240 602fd350-edb4-49c9-b593-d223f7449a82
This commit includes in the core settings for the gradients theme API stabilized in WordPress/gutenberg#20107, and for the image sizes required for the latest posts feature image WordPress/gutenberg#17151. Props: youknowriad, ryelle. Fixes #49389. Built from https://develop.svn.wordpress.org/trunk@47240 git-svn-id: http://core.svn.wordpress.org/trunk@47040 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit includes in the core settings for the gradients theme API stabilized in WordPress/gutenberg#20107, and for the image sizes required for the latest posts feature image WordPress/gutenberg#17151. Props: youknowriad, ryelle. Fixes #49389. Built from https://develop.svn.wordpress.org/trunk@47240 git-svn-id: https://core.svn.wordpress.org/trunk@47040 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit includes in the core settings for the gradients theme API stabilized in WordPress/gutenberg#20107, and for the image sizes required for the latest posts feature image WordPress/gutenberg#17151. Props: youknowriad, ryelle. Fixes #49389. Built from https://develop.svn.wordpress.org/trunk@47240
This commit includes in the core settings for the gradients theme API stabilized in WordPress/gutenberg#20107, and for the image sizes required for the latest posts feature image WordPress/gutenberg#17151. Props: youknowriad, ryelle. Fixes #49389. git-svn-id: http://develop.svn.wordpress.org/trunk@47240 602fd350-edb4-49c9-b593-d223f7449a82
@ryelle, @jorgefilipecosta: the introduction of The Gutenberg plugin requires WordPress 5.2.0+. We should either bump that to 5.3.0, or guard against missing |
Reported in #20484. |
Description
See #1594. This PR builds on #17148 to add featured image to the Latest Posts block. It uses that new
ImageSizeControl
control and adds an alignment control for image alignment.Screenshots
Editor
Sidebar
Front end
Still To Do
imageHeight
&imageWidth
, which function as a basis for the resizing. For a single image, this is literally the width & height of that particular image. For this block, we can use the site defaults for each image size? — This seems to work just fine ✅To Test