Skip to content

Commit

Permalink
Improving images (#911)
Browse files Browse the repository at this point in the history
* Adds custom image element
  • Loading branch information
robdy authored Nov 28, 2023
1 parent cbdf95a commit 7d0603c
Show file tree
Hide file tree
Showing 29 changed files with 56 additions and 17 deletions.
2 changes: 2 additions & 0 deletions blogdev/2022-07-23-test-page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ tags:
- powershell
---

![Database query response](../../imgdev/Untitled-8.png)

Redownloading the media from PowerApps app is no longer available out of the box. Let’s explore the workarounds we have!

```powershell
Expand Down
30 changes: 14 additions & 16 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ module.exports = {
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
path: `${__dirname}/blog${process.env.NODE_ENV === 'production' ? '' : 'dev'}`,
name: 'articles',
},
resolve: 'gatsby-source-filesystem',
options: {
path: `${__dirname}/blog${process.env.NODE_ENV === 'production' ? '' : 'dev'}`,
name: 'articles',
},
},
{
resolve: 'gatsby-source-filesystem',
Expand All @@ -34,7 +34,15 @@ module.exports = {
name: 'images',
},
},
'gatsby-plugin-sharp',
`gatsby-plugin-image`,
{
resolve: `gatsby-plugin-sharp`,
options: {
defaults: {
breakpoints: [471, 942, 1920]
}
}
},
'gatsby-transformer-sharp',
{
resolve: 'gatsby-plugin-mdx',
Expand All @@ -46,16 +54,6 @@ module.exports = {
// name: 'uploads',
},
},
{
resolve: 'gatsby-remark-images',
options: {
// It's important to specify the maxWidth (in pixels) of
// the content container as this plugin uses this as the
// base for generating different widths of each image.
maxWidth: 1920,
srcSetBreakpoints: [471, 942],
},
},
{
resolve: 'gatsby-remark-copy-linked-files',
options: {
Expand Down
31 changes: 31 additions & 0 deletions src/components/Image.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react'
import { GatsbyImage } from 'gatsby-plugin-image'
import { graphql, useStaticQuery } from 'gatsby'

export const Image = ({ alt, src }) => {
const data = useStaticQuery(graphql`
query ImageQuery {
allFile {
nodes {
childImageSharp {
gatsbyImageData
}
relativePath
absolutePath
}
}
}
`)
const relatedSrc = src.slice(6)
const relatedImage = data.allFile.nodes.find(node => node.absolutePath.includes(relatedSrc))

if (!relatedImage) return (<p style={{ color: 'red' }}>{alt} Image NOT FOUND</p>)

return (
<>
<GatsbyImage image={relatedImage.childImageSharp.gatsbyImageData} alt={alt} title={alt} />
<p className="image-title">{alt}</p>
</>
)
}
2 changes: 2 additions & 0 deletions src/components/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { NoteBlock, WarningBlock, TipBlock } from './Block'
import { LinkToAnywhere } from './LinkToAnywhere'
import { Header } from './Header'
import { CodeBlock } from './CodeBlock'
import { Image } from './Image'

const TemplateWrapper = ({ children }) => {

Expand All @@ -24,6 +25,7 @@ const TemplateWrapper = ({ children }) => {
h5: props => <Header level={'5'} {...props} />,
h6: props => <Header level={'6'} {...props} />,
pre: CodeBlock,
img: Image,
}}
>
{children}
Expand Down
1 change: 0 additions & 1 deletion src/components/ReadingProgress.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const ReadingProgress = () => {
'width': `${scrollProgress}%`,

};
console.log(scrollProgress)

return (
<div className="reading-progress-bar">
Expand Down
7 changes: 7 additions & 0 deletions src/components/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,13 @@ h6 {
margin-top: var(--header-top-margin);
}

p.image-title {
font-size: 0.8rem;
text-align: center;
margin-top: 0.5rem;
margin-bottom: 0.5rem;
}

/*#region Header anchors */
.anchor.before {
position: absolute;
Expand Down
Binary file added src/imgdev/Untitled-8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/imgdev/teams-wiki-retirement/zWcpmWZFjX.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7d0603c

Please sign in to comment.