Skip to content

Commit c58761b

Browse files
authored
Merge pull request #195 from BuildFire/dicebear-croped-image
fix(dicebear-image): use scale query for layout1,2
2 parents 563ca31 + b1a82e1 commit c58761b

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

control/content/app.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@
169169
}])
170170
.filter('getImageUrl', function () {
171171
return function (url, width, height, type) {
172+
if (url.includes('dicebear')){
173+
let urlObj = new URL(url);
174+
let params = urlObj.searchParams;
175+
params.delete('scale');
176+
url = urlObj.origin + urlObj.pathname + '?' + params.toString();
177+
}
172178
if (type == 'resize')
173179
return buildfire.imageLib.resizeImage(url, {
174180
width: width,

control/content/js/aiStateSeederManager.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ const aiStateSeederManager = {
4040
userMessage:
4141
'Generate a sample list of contacts for people working in the field of [business-type]',
4242
systemMessage:
43-
'Each contact should have a first name, last name, phone number, avatar in png format, bio, position, rank is item order number starting from zero, and email. Use https://api.dicebear.com/8.x/avataaars/png to generate useable avatar URLs, bio as HTML content, and for first name and last name use gender-neutral names, rank must be type number',
43+
'Each contact should have a first name, last name, phone number, avatar in png format, bio, position, rank is item order number starting from zero, and email. Use https://api.dicebear.com/8.x/avataaars/png?scale=50 to generate useable avatar URLs, bio as HTML content, and for first name and last name use gender-neutral names, rank must be type number',
4444
jsonTemplate: this.jsonTemplate,
4545
callback: this._handleGenerate.bind(this),
4646
},
4747

4848
importOptions: {
4949
jsonTemplate: this.jsonTemplate,
5050
sampleCSV:
51-
'Jane, Smith, 123-456-7890, https://api.dicebear.com/8.x/avataaars/png?seed=jane-smith&mouth=smile&eyebrows=defaultNatural&eyes=default,Jane Smith is a marketing specialist with expertise in digital marketing strategies.,Marketing Specialist,Jane.Smith@example.com\nJohn, Doe, 123-456-7890, https://api.dicebear.com/8.x/avataaars/png?seed=john-doe&mouth=smile&eyebrows=defaultNatural&eyes=default,John Doe is a software engineer with 5 years of experience in web development.,Software Engineer,john.doe@example.com',
51+
'Jane, Smith, 123-456-7890, https://api.dicebear.com/8.x/avataaars/png?seed=jane-smith&mouth=smile&eyebrows=defaultNatural&eyes=default&scale=50, Jane Smith is a marketing specialist with expertise in digital marketing strategies.,Marketing Specialist,Jane.Smith@example.com\nJohn, Doe, 123-456-7890, https://api.dicebear.com/8.x/avataaars/png?seed=john-doe&mouth=smile&eyebrows=defaultNatural&eyes=default&scale=50, John Doe is a software engineer with 5 years of experience in web development.,Software Engineer,john.doe@example.com',
5252
systemMessage: `fName is first , last name is lname, phone is random phone numbers, topImage is a URL`,
5353
callback: this._handleImport.bind(this),
5454
},
@@ -185,7 +185,7 @@ const aiStateSeederManager = {
185185
item.fName = item.fName || 'N/A';
186186
item.lName = item.lName || '';
187187
item.phone = item.phone || 'N/A';
188-
item.topImage = item.topImage || `https://api.dicebear.com/8.x/initials/png?seed=${item.fName}%20${item.lName}&backgroundColor=808080`;
188+
item.topImage = item.topImage || `https://api.dicebear.com/8.x/initials/png?seed=${item.fName}%20${item.lName}&backgroundColor=808080&scale=50`;
189189
item.bodyContent = item.bodyContent || 'N/A';
190190
item.position = item.position || 'N/A';
191191
item.email = item.email || 'N/A';

widget/app.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@
9494

9595
attrs.$observe('finalSrc', function() {
9696
var _img = attrs.finalSrc;
97+
if (_img.includes('dicebear') && attrs.dicebearScale){
98+
let urlObj = new URL(_img);
99+
let params = urlObj.searchParams;
100+
params.delete('scale');
101+
_img = urlObj.origin + urlObj.pathname + '?' + params.toString();
102+
}
97103

98104
if (attrs.cropType == 'resize') {
99105
Buildfire.imageLib.local.resizeImage(_img, {
@@ -164,7 +170,7 @@
164170
} else {
165171
buildfire.navigation._goBackOne();
166172
}
167-
173+
168174
};
169175

170176
buildfire.history.onPop(function(data, err){

widget/templates/layouts/list-layout-3.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<div class="list-items list-layout" ng-if="WidgetHome.data" infinite-scroll-distance="1" data-infinite-container=".infinite-scroll-parent" infinite-scroll="WidgetHome.loadMore(undefined,undefined,true)" infinite-scroll-disabled="WidgetHome.noMore">
1313
<div class="list-item" ng-repeat="item in WidgetHome.items" ng-click="WidgetHome.getPeopleDetails(item.id)">
1414
<div ng-if="item.data.topImage" class="media">
15-
<img class="people-thumbnail-img text-overlay-round" load-image="1x1" crop-width="120" crop-height="120" crop-type="crop" data-final-src="{{item.data.topImage}}">
15+
<img class="people-thumbnail-img text-overlay-round" load-image="1x1" crop-width="120" crop-height="120" crop-type="crop" dicebear-scale="1" data-final-src="{{item.data.topImage}}">
1616
</div>
1717
<!-- <div ng-if="!item.data.topImage" class="media pull-left border-radius-four people-thumbnail margin-right-ten" ng-click="WidgetHome.getPeopleDetails(item.id)">
1818
<div class="people-thumbnail-img text-overlay" style="background-image: url(../../../styles/media/holder-2x1.png); background-size: cover; background-position: center;height: 60px"></div>

0 commit comments

Comments
 (0)