How to use photon - 8 common examples

To help you get started, we’ve selected a few photon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Automattic / wp-calypso / client / my-sites / marketing / buttons / preview-button.jsx View on Github external
tumblr: 'tumblr-alt',
			'jetpack-whatsapp': 'whatsapp',
			'press-this': 'wordpress',
			twitter: 'twitter-alt',
			more: 'share',
		};
		if ( ! this.props.button.custom ) {
			const icon = shortnameToSocialLogo[ this.props.button.ID ] || this.props.button.shortname;

			return ;
		} else if ( 'string' === typeof this.props.button.icon ) {
			return (
				<span style="{">
			);
		}
	}
	/* eslint-enable wpcalypso/jsx-classname-namespace */</span>
github Automattic / wp-calypso / client / my-sites / theme / main.jsx View on Github external
renderScreenshot() {
		const { isWpcomTheme, name: themeName } = this.props;
		const screenshotFull = isWpcomTheme ? this.getFullLengthScreenshot() : this.props.screenshot;
		const width = 735;
		// Photon may return null, allow fallbacks
		const photonSrc = screenshotFull &amp;&amp; photon( screenshotFull, { width } );
		const img = screenshotFull &amp;&amp; (
			<img srcset="{" src="{" alt="{">
		);

		if ( this.isThemeAvailable() ) {
			return (
github Automattic / wp-calypso / client / components / theme / index.jsx View on Github external
<button href="{">
							{ translate( 'Upgrade Now' ) }
						</button>
					
				
			
		);

		const fit = '479,360';
		const themeImgSrc = photon( screenshot, { fit } );
		const themeImgSrcDoubleDpi = photon( screenshot, { fit, zoom: 2 } );
		const e2eThemeName = name.toLowerCase().replace( /\s+/g, '-' );

		return (
			
				{ this.isBeginnerTheme() &amp;&amp; (
					
						{ translate( 'Beginner' ) }
					
				) }
				<div>
					</div>
github Automattic / wp-calypso / client / components / signup-site-preview / screenshot.tsx View on Github external
const onLoad = ( event: React.SyntheticEvent&lt; HTMLImageElement &gt; ) =&gt; {
		setWrapperHeight( event.currentTarget.height );
		setIsLoading( false );
	};

	return (
		<div>
			{ isLoading &amp;&amp; (
				
			) }
			{ /* The onClick is being used for analytics purposes, there's no user interaction implemented with this click handler */ }
			{ /* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions */ }
			<img srcset="{" width="" src="{" style="{"> onPreviewClick( defaultViewportDevice ) }
				onLoad={ onLoad }
				alt={
					isPhone
						? translate( 'Preview of site with phone layout', {
								comment: 'alt text of site preview',
						  } )
						: translate( 'Preview of site with desktop layout', {
								comment: 'alt text of site preview',
						  } )
				}
			/&gt;
		</div>
	);
}
github Automattic / wp-calypso / client / my-sites / theme / main.jsx View on Github external
renderScreenshot() {
		const { isWpcomTheme, name: themeName } = this.props;
		const screenshotFull = isWpcomTheme ? this.getFullLengthScreenshot() : this.props.screenshot;
		const width = 735;
		// Photon may return null, allow fallbacks
		const photonSrc = screenshotFull &amp;&amp; photon( screenshotFull, { width } );
		const img = screenshotFull &amp;&amp; (
			<img srcset="{" src="{" alt="{">
		);

		if ( this.isThemeAvailable() ) {
			return (
				<a rel="noopener noreferrer" href="{">
					{ this.shouldRenderPreviewButton() &amp;&amp; this.renderPreviewButton() }
					{ img }
				</a>
			);
		}
github Automattic / wp-calypso / client / my-sites / media-library / list-item-video.jsx View on Github external
render() {
		const thumbnail = this.getHighestQualityThumbnail();

		if ( thumbnail ) {
			// Non MEDIA_IMAGE_THUMBNAIL video media is accessible via Photon
			const url =
				this.props.thumbnailType === MEDIA_IMAGE_THUMBNAIL
					? thumbnail
					: photon( thumbnail, { width: this.props.maxImageWidth } );

			return (
				<div style="{">
					<span>
						
					</span>
				</div>
			);
		}
		return ;
	}
}
github Automattic / wp-calypso / client / components / signup-site-preview / screenshot.tsx View on Github external
const onLoad = ( event: React.SyntheticEvent&lt; HTMLImageElement &gt; ) =&gt; {
		setWrapperHeight( event.currentTarget.height );
		setIsLoading( false );
	};

	return (
		<div>
			{ isLoading &amp;&amp; (
				
			) }
			{ /* The onClick is being used for analytics purposes, there's no user interaction implemented with this click handler */ }
			{ /* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions */ }
			<img srcset="{" width="" src="{" style="{"> onPreviewClick( defaultViewportDevice ) }
				onLoad={ onLoad }
				alt={
					isPhone
						? translate( 'Preview of site with phone layout', {
								comment: 'alt text of site preview',
						  } )
						: translate( 'Preview of site with desktop layout', {
								comment: 'alt text of site preview',
						  } )
				}
			/&gt;
		</div>
	);
}
github TooTallNate / n8.io-old / server / favicon.js View on Github external
export default async function (req, res) {
  const img = gravatar('nathan@tootallnate.net');
  const url = photon(img, { filter: 'grayscale' });

  debug('redirecting %o -> %o', req.url, url);
  res.statusCode = 302;
  res.setHeader('Location', url);
  res.end();
}

photon

JavaScript library for the WordPress.com Photon image manipulation service

GPL-2.0
Latest version published 3 years ago

Package Health Score

75 / 100
Full package analysis

Popular photon functions