Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fixing diaporama orientation
Browse files Browse the repository at this point in the history
  • Loading branch information
ghecquet committed Jun 2, 2017
1 parent 47244b6 commit 41eaa82
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions core/src/plugins/editor.diaporama/res/js/editor.js
Expand Up @@ -81,10 +81,19 @@ class Editor extends PureComponent {
}

render() {
const {node, src, editorData} = this.props;
const {node, src, orientation, editorData} = this.props;

if (!node) return null

let imageClassName = ['diaporama-image-main-block']

if (orientation) {
imageClassName = [
...imageClassName,
'ort-rotate-' + orientation
];
}

return (
<ContainerSizeProvider>
{({containerWidth, containerHeight}) =>
Expand All @@ -98,7 +107,7 @@ class Editor extends PureComponent {
height={imgHeight}
containerWidth={containerWidth}
containerHeight={containerHeight}
imgClassName="diaporama-image-main-block"
imgClassName={imageClassName.join(" ")}
style={{backgroundColor:'#424242'}}
imgStyle={{boxShadow: 'rgba(0, 0, 0, 0.117647) 0px 1px 6px, rgba(0, 0, 0, 0.117647) 0px 1px 4px'}}
/>
Expand All @@ -123,10 +132,25 @@ const getSelection = (node) => new Promise((resolve, reject) => {
})
})

const mapStateToProps = (state, props) => {
const {tabs} = state
const tab = tabs.filter(({editorData, node}) => (!editorData || editorData.id === props.editorData.id) && node.getPath() === props.node.getPath())[0] || {}

if (!tab) return props

const {node, resolution} = tab

return {
orientation: resolution === 'hi' ? node.getMetadata().get("image_exif_orientation") : null,
...props
}
}

export default compose(
withSelection(getSelection, getSelectionFilter),
withResolution(sizes,
(node) => `${baseURL}&action=preview_data_proxy&file=${encodeURIComponent(node.getPath())}`,
(node, dimension) => `${baseURL}&action=preview_data_proxy&get_thumb=true&dimension=${dimension}&file=${encodeURIComponent(node.getPath())}`
)
),
connect(mapStateToProps)
)(Editor)

0 comments on commit 41eaa82

Please sign in to comment.