Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 4 additions & 3 deletions 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 Expand Up @@ -89,8 +90,8 @@ module.exports = [
hints: 'error',
}
: {
maxAssetSize: 71680,
maxEntrypointSize: 71680,
maxAssetSize: 102400,
maxEntrypointSize: 102400,
hints: 'error',
},
},
Expand Down