-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Gallery: Add link to option #2164
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2164 +/- ##
==========================================
+ Coverage 23.83% 24.12% +0.28%
==========================================
Files 142 142
Lines 4459 4609 +150
Branches 756 794 +38
==========================================
+ Hits 1063 1112 +49
- Misses 2866 2933 +67
- Partials 530 564 +34
Continue to review full report at Codecov.
|
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.
While testing this out I hit an issue with linking to the attachment page. Steps to reproduce:
1- Add new gallery block
2- Select a few images
3- Link To "Attachment Page"
4- Save
When viewing the post on the front-end of the site, the images in the gallery are not linked. It does work for linking to "Media File"
blocks/library/gallery/index.js
Outdated
<SelectControl | ||
label={ __( 'Link to' ) } | ||
selected={ linkto } | ||
onBlur={ setLinkto } |
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.
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.
Ah good point, I'll update.
I also re-triggered the CI job that had failed, all looks green now. |
17a95c4
to
3e6e04f
Compare
@timmyc the Attachment link is weird - it works for some of my test images but not others, trying to figure out why since the data should be accurate |
@mkaz so I thought it might have just been certain images in my library too... but I tested with the same images using the gallery flow in the current editor and the links worked okay for me there with "attachment" selected. I didn't debug further, but thought something in the following line might be the culprit:
|
); | ||
} | ||
|
||
if ( props.linkto === 'attachment' && !! props.img.link ) { |
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'd be nice to not duplicate the markup for links and do this instead:
https://github.com/WordPress/gutenberg/blob/master/blocks/library/image/index.js#L200
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.
👍
2b51b87
to
47172d1
Compare
blocks/library/gallery/index.js
Outdated
@@ -71,9 +77,11 @@ registerBlockType( 'core/gallery', { | |||
|
|||
edit( { attributes, setAttributes, focus, className } ) { | |||
const { images = [], columns = defaultColumnsNumber( attributes ), align = 'none' } = attributes; | |||
const setLinkto = ( value ) => setAttributes( { linkto: value } ); |
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.
tiny thing, but probably should camel case the linkTo
:)
blocks/library/gallery/index.js
Outdated
const setColumnsNumber = ( event ) => setAttributes( { columns: event.target.value } ); | ||
const updateAlignment = ( nextAlign ) => setAttributes( { align: nextAlign } ); | ||
const { imageCrop = true } = attributes; | ||
const { linkto = 'none' } = attributes; |
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.
These could be moved to default attrs:
defaultAttributes: {
dropCap: false,
},
Also maybe the label + input could all fit in one row? |
@mtias I'm just using the SelectControl component and don't see any real options on how to keep it all on the same row - any suggestion? |
That's fine, we could look into the component itself in the future. |
@@ -5,7 +5,7 @@ export default function GalleryImage( props ) { | |||
case 'media': | |||
href = props.img.url; | |||
break; | |||
case 'attacment': | |||
case 'attachment': |
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 always misspell that word too - funny that i didn't catch that when reviewing. 😄
* Release v1.26.0 (#2153) * Add tests for Latest-Posts Bock * Have the Automation tests Scroll the Block window to help locate Block buttons on Android * Update gutenberg reference * Update Gutenberg ref * Update Gutenberg ref * New template for release PRs This PR will add a new template for release PRs to make it easier to check all the steps needed and to standardize the release PRs. This template can then be used by using this link: `https://github.com/wordpress-mobile/gutenberg-mobile/pull/new?template=release_pull_request.md` * Update template file. * Fix: remove extra padding for post title and first `Paragraph` block (#2095) * Fix: remove extra padding for post title and first `Paragraph` block * Update Gutenberg ref * Add a new androidReplacements function to comply with Android Typography lint rules * Make sure the file gutenberg.pot exists before generating android and ios strings. * Update Gutenberg ref * Update gutenberg ref * Update gutenberg ref * Update gutenberg reference * Gutenberg update * Update Gutenberg ref * Update Gutenberg ref * Update Gutenberg ref * Update Gutenberg ref * Fix: prevent ripple effect on slider cell in BottomSheet and disable it completely on iOS (#2023) * prevent ripple effect on slider cell in BottomSheet and disable it completely on iOS * Update Gutenberg ref * Update Gutenberg ref * Accept multiple headers through OnAuthHeaderRequestedListener (#2080) * Blog layout template (#2114) * Update Gutenberg ref * Update Gutenberg ref * Update gutenberg reference * Fix failing UI tests Try scrolling in the Inserter for all platforms * Disable the failing test on iOS Co-authored-by: Matthew Kevins <[email protected]> Co-authored-by: Pinar Olguc <[email protected]> * Update gutenberg reference * Feat: Column block (#1661) * update ref to master (Columns Block) * Update gutenberg reference * Fix Latests Posts Tests by expanding the scroll to button functionality * Fix lint issue * Fix typography breakage in master To a version where the typography panel is not added to block settings. * Update GB reference. * Correct slider step value (#2119) * Update ref: Correct slider step accordingly to the platform * Update gb ref Co-authored-by: Pinar Olguc <[email protected]> * v1.26.0 * Add some missing release notes * Update Podfile.lock * Update gb ref * Update bundles Co-authored-by: Chip Snyder <[email protected]> Co-authored-by: Matthew Kevins <[email protected]> Co-authored-by: Gerardo Pacheco <[email protected]> Co-authored-by: Sérgio Estêvão <[email protected]> Co-authored-by: jbinda <[email protected]> Co-authored-by: Chip <[email protected]> Co-authored-by: Maxime Biais <[email protected]> Co-authored-by: Tugdual de Kerviler <[email protected]> Co-authored-by: Klymentiy Haykov <[email protected]> Co-authored-by: Matthew Kevins <[email protected]> Co-authored-by: Luke Walczak <[email protected]> * Update gb ref Co-authored-by: Chip Snyder <[email protected]> Co-authored-by: Matthew Kevins <[email protected]> Co-authored-by: Gerardo Pacheco <[email protected]> Co-authored-by: Sérgio Estêvão <[email protected]> Co-authored-by: jbinda <[email protected]> Co-authored-by: Chip <[email protected]> Co-authored-by: Maxime Biais <[email protected]> Co-authored-by: Tugdual de Kerviler <[email protected]> Co-authored-by: Klymentiy Haykov <[email protected]> Co-authored-by: Matthew Kevins <[email protected]> Co-authored-by: Luke Walczak <[email protected]>
Allow user to select link to option for images similar to core gallery.
Add to Inspector Link To options: Attachment Page, Media File, or None.
See: #1448