Skip to content

Commit

Permalink
Instant Search: add basic Photon support (#13998)
Browse files Browse the repository at this point in the history
* Add PhotonImage component

* Bump default dimensions to 300x300

* Bump asset size limit to 100kb
  • Loading branch information
bluefuton authored and gibrown committed Dec 2, 2019
1 parent 6d3ac2b commit c2d1c45
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
15 changes: 15 additions & 0 deletions modules/search/instant-search/components/photon-image.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/** @jsx h */

/**
* External dependencies
*/
import { h } from 'preact';
import photon from 'photon';

const PhotonImage = ( { src, maxWidth = 300, maxHeight = 300, alt, ...otherProps } ) => {
const photonSrc = photon( src, { resize: `${ maxWidth },${ maxHeight }` } );

return <img src={ photonSrc } alt={ alt } { ...otherProps } />;
};

export default PhotonImage;
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { h, Component } from 'preact';
* Internal dependencies
*/
import SearchResultComments from './search-result-comments';
import PhotonImage from './photon-image';

class SearchResultProduct extends Component {
render() {
Expand All @@ -34,7 +35,7 @@ class SearchResultProduct extends Component {
/>
</h3>
{ firstImage && (
<img
<PhotonImage
className="jetpack-instant-search__search-result-product-img"
src={ `//${ firstImage }` }
alt=""
Expand Down
3 changes: 2 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const sharedWebpackConfig = {
devtool: isDevelopment ? 'source-map' : false,
};

// We export two configuration files: One for admin.js, and one for static.jsx. The latter produces pre-rendered HTML.
// We export two main configuration files: One for admin.js, and one for static.jsx. The latter produces pre-rendered HTML.
// The third configuration file is for Jetpack Search's Preact app.
module.exports = [
{
...sharedWebpackConfig,
Expand Down

0 comments on commit c2d1c45

Please sign in to comment.