-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPhoto.js
More file actions
55 lines (48 loc) · 1.57 KB
/
Photo.js
File metadata and controls
55 lines (48 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Image, Transformation } from 'cloudinary-react';
import { url } from '../utils/CloudinaryService';
import PhotoThumbnails from './PhotoThumbnails';
import {CloudinaryContext} from 'cloudinary-react';
class Photo extends Component {
constructor(props) {
super(props);
this.state = { showMore: false };
}
render() {
const options = { ...this.context, ...this.props };
const urlPath = url(options.publicId, options);
console.log(this.props)
return (
<div className="photo">
{this.props.context && (
<h2>{this.props.context.custom.location}</h2>
)}
<a href={urlPath} target="_blank" rel="noopener noreferrer">
<Image
publicId={this.props.publicId}
className="thumbnail inline"
width="150"
height="150"
crop="fit"
quality="80"
>
<Transformation quality="auto" fetchFormat="auto" />
</Image>
</a>
</div>
);
}
showMore() {
this.setState({ showMore: true });
}
showLess() {
this.setState({ showMore: false });
}
static contextType = CloudinaryContext.contextType;
}
Photo.propTypes = {
context: PropTypes.object,
publicId: PropTypes.string,
};
export default Photo;