mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 01:25:52 -05:00
generate author thumbnail and pass to gui
This commit is contained in:
parent
464d5f7c2d
commit
c965fd15f9
2 changed files with 22 additions and 0 deletions
17
src/lib/user-thumbnail.js
Normal file
17
src/lib/user-thumbnail.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* @user-thumbnail
|
||||
* Utility functions to return thumnail-related strings
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generate a thumbnail url for a particular userid, with width and height.
|
||||
* @param {string} userId userId for the user whose thumbnail we want
|
||||
* @param {number} width desired thumbnail width; defaults to 32
|
||||
* @param {number} height desired thumbnail height; defaults to width.
|
||||
* @returns {string} thumbnail url string
|
||||
*/
|
||||
const thumbnailUrl = (userId, width, height) => (
|
||||
`/get_image/user/${userId}_${width ? width : 32}x${height ? height : (width ? width : 32)}.png`
|
||||
);
|
||||
|
||||
module.exports = thumbnailUrl;
|
|
@ -13,6 +13,7 @@ const storage = require('../../lib/storage.js').default;
|
|||
const log = require('../../lib/log');
|
||||
const EXTENSION_INFO = require('../../lib/extensions.js').default;
|
||||
const jar = require('../../lib/jar.js');
|
||||
const thumbnailUrl = require('../../lib/user-thumbnail');
|
||||
|
||||
const PreviewPresentation = require('./presentation.jsx');
|
||||
const projectShape = require('./projectshape.jsx').projectShape;
|
||||
|
@ -453,11 +454,13 @@ class Preview extends React.Component {
|
|||
hideIntro
|
||||
assetHost={this.props.assetHost}
|
||||
authorId={this.props.authorId}
|
||||
authorThumbnailUrl={this.props.authorThumbnailUrl}
|
||||
authorUsername={this.props.authorUsername}
|
||||
backpackOptions={this.props.backpackOptions}
|
||||
basePath="/"
|
||||
canCreateCopy={this.props.canCreateCopy}
|
||||
canCreateNew={this.props.canCreateNew}
|
||||
canEditTitle={this.props.isEditable}
|
||||
canRemix={this.props.canRemix}
|
||||
canSave={this.props.canSave}
|
||||
canShare={this.props.canShare}
|
||||
|
@ -488,6 +491,7 @@ class Preview extends React.Component {
|
|||
Preview.propTypes = {
|
||||
assetHost: PropTypes.string.isRequired,
|
||||
authorId: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
||||
authorThumbnailUrl: PropTypes.string,
|
||||
authorUsername: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
||||
backpackOptions: PropTypes.shape({
|
||||
host: PropTypes.string,
|
||||
|
@ -591,6 +595,7 @@ const mapStateToProps = state => {
|
|||
|
||||
return {
|
||||
authorId: authorId,
|
||||
authorThumbnailUrl: thumbnailUrl(authorId),
|
||||
authorUsername: authorUsername,
|
||||
canAddToStudio: userOwnsProject,
|
||||
canCreateCopy: userOwnsProject && projectInfoPresent,
|
||||
|
|
Loading…
Reference in a new issue