diff --git a/ghost/admin/assets/sass/components/navigation.scss b/ghost/admin/assets/sass/components/navigation.scss index 0e8948f725..b740b0197f 100644 --- a/ghost/admin/assets/sass/components/navigation.scss +++ b/ghost/admin/assets/sass/components/navigation.scss @@ -125,14 +125,9 @@ // Profile picture .image { - float: left; - margin: 15px 8px 0 0; - - img { - display: block; - width: 30px; - height: 30px; - border-radius: 100%; + @include circular-image(30px) { + float: left; + margin: 15px 14px 0 0; } } diff --git a/ghost/admin/assets/sass/layouts/content.scss b/ghost/admin/assets/sass/layouts/content.scss index be9d4ebabc..59f4815f22 100644 --- a/ghost/admin/assets/sass/layouts/content.scss +++ b/ghost/admin/assets/sass/layouts/content.scss @@ -122,12 +122,10 @@ } .avatar { - width: 18px; - height: 18px; - border-radius: 18px; - margin-right: 14px; - float: left; // Used instead of `display: block;` to remove the stupid space under the image. - object-fit: cover; // Like using 'background-size: cover;', but on an img tag - https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit + @include circular-image(18px) { + float: left; // Used instead of `display: block;` to remove the stupid space under the image. + margin-right: 14px; + } } .status, diff --git a/ghost/admin/assets/sass/layouts/users.scss b/ghost/admin/assets/sass/layouts/users.scss index 075fb0a061..d980b4064e 100644 --- a/ghost/admin/assets/sass/layouts/users.scss +++ b/ghost/admin/assets/sass/layouts/users.scss @@ -97,13 +97,9 @@ a.user-list-item { } .user-list-item-figure { - width: 35px; - height: 35px; - display: block; - border: 1px solid #979797; - border-radius: 100%; - background-size: cover; - background-position: center center; + @include circular-image(35px) { + display: block; + } } .user-list-item-icon, diff --git a/ghost/admin/assets/sass/modules/mixins.scss b/ghost/admin/assets/sass/modules/mixins.scss index 3871bbe91f..428675cf4b 100644 --- a/ghost/admin/assets/sass/modules/mixins.scss +++ b/ghost/admin/assets/sass/modules/mixins.scss @@ -8,6 +8,7 @@ // * tab-focus() // * triangle() // * set-triangle-color() +// * circular-image() // ------------------------------------------------------------ @@ -99,4 +100,29 @@ } @else { @return "transparent"; } +} + + +// +// Reusable styles for creating a circular image which is cropped properly, with the image inside it +// Example: @circular-image(35px); +// -------------------------------------------------- + +@mixin circular-image($widthandheight: 20px) { + @content; + width: $widthandheight; + height: $widthandheight; + border-radius: $widthandheight; + background-size: cover; + background-position: center center; + position: relative; + + img { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + opacity: 0; + } } \ No newline at end of file diff --git a/ghost/admin/controllers/application.js b/ghost/admin/controllers/application.js index 951490fd45..ef92105d03 100644 --- a/ghost/admin/controllers/application.js +++ b/ghost/admin/controllers/application.js @@ -7,10 +7,18 @@ var ApplicationController = Ember.Controller.extend({ showGlobalMobileNav: false, showSettingsMenu: false, - userImageAlt: Ember.computed('session.user.name', function () { + userImage: Ember.computed('session.user.image', function () { + return this.get('session.user.image') || this.get('ghostPaths.url').asset('/shared/img/user-image.png'); + }), + + userImageBackground: Ember.computed('userImage', function () { + return 'background-image: url(' + this.get('userImage') + ')'; + }), + + userImageAlt: Ember.computed('session.user.name', function () { var name = this.get('session.user.name'); - return name + '\'s profile picture'; + return (name) ? name + '\'s profile picture' : 'Profile picture'; }), actions: { diff --git a/ghost/admin/controllers/posts/post.js b/ghost/admin/controllers/posts/post.js index adfdb369ee..40f655176c 100644 --- a/ghost/admin/controllers/posts/post.js +++ b/ghost/admin/controllers/posts/post.js @@ -10,6 +10,10 @@ var PostController = Ember.Controller.extend({ return this.get('model.author.image') || this.get('ghostPaths.url').asset('/shared/img/user-image.png'); }), + authorAvatarBackground: Ember.computed('authorAvatar', function () { + return 'background-image: url(' + this.get('authorAvatar') + ')'; + }), + actions: { toggleFeatured: function () { var options = {disableNProgress: true}, diff --git a/ghost/admin/templates/-navbar.hbs b/ghost/admin/templates/-navbar.hbs index 89b04ef9ae..54cdb4a3ec 100644 --- a/ghost/admin/templates/-navbar.hbs +++ b/ghost/admin/templates/-navbar.hbs @@ -31,11 +31,9 @@