Skip to content

Commit eece4c0

Browse files
committed
feat: redirect to unsplash as attribution is now a utm link instead of plain text
1 parent 9a66f5d commit eece4c0

File tree

1 file changed

+33
-18
lines changed

1 file changed

+33
-18
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,7 +2145,7 @@ function RemoteFunctions(config = {}) {
21452145
line-height: 1.2 !important;
21462146
max-width: calc(100% - 12px) !important;
21472147
text-shadow: 0 1px 2px rgba(0,0,0,0.9) !important;
2148-
pointer-events: none !important;
2148+
pointer-events: auto !important;
21492149
opacity: 0 !important;
21502150
transition: all 0.2s ease !important;
21512151
}
@@ -2156,12 +2156,24 @@ function RemoteFunctions(config = {}) {
21562156
white-space: nowrap !important;
21572157
overflow: hidden !important;
21582158
text-overflow: ellipsis !important;
2159+
color: white !important;
2160+
text-decoration: none !important;
2161+
}
2162+
2163+
.phoenix-ribbon-attribution .photographer:hover {
2164+
text-decoration: underline !important;
21592165
}
21602166
21612167
.phoenix-ribbon-attribution .source {
21622168
display: block !important;
21632169
font-size: 9px !important;
21642170
opacity: 0.85 !important;
2171+
color: white !important;
2172+
text-decoration: none !important;
2173+
}
2174+
2175+
.phoenix-ribbon-attribution .source:hover {
2176+
text-decoration: underline !important;
21652177
}
21662178
21672179
.phoenix-download-icon {
@@ -2195,6 +2207,10 @@ function RemoteFunctions(config = {}) {
21952207
opacity: 1 !important;
21962208
}
21972209
2210+
.phoenix-ribbon-attribution:hover {
2211+
opacity: 1 !important;
2212+
}
2213+
21982214
.phoenix-download-icon:hover {
21992215
background: rgba(0,0,0,0.9) !important;
22002216
transform: scale(1.1) !important;
@@ -2533,14 +2549,25 @@ function RemoteFunctions(config = {}) {
25332549
const attribution = window.document.createElement('div');
25342550
attribution.className = 'phoenix-ribbon-attribution';
25352551

2536-
const photographer = window.document.createElement('span');
2552+
const photographer = window.document.createElement('a');
25372553
photographer.className = 'photographer';
2538-
const photographerName = this._getPhotographerName(image);
2539-
photographer.textContent = photographerName;
2554+
photographer.href = image.photographer_url;
2555+
photographer.target = '_blank';
2556+
photographer.rel = 'noopener noreferrer';
2557+
photographer.textContent = (image.user && image.user.name) || 'Anonymous';
2558+
photographer.addEventListener('click', (e) => {
2559+
e.stopPropagation();
2560+
});
25402561

2541-
const source = window.document.createElement('span');
2562+
const source = window.document.createElement('a');
25422563
source.className = 'source';
2564+
source.href = image.unsplash_url;
2565+
source.target = '_blank';
2566+
source.rel = 'noopener noreferrer';
25432567
source.textContent = 'on Unsplash';
2568+
source.addEventListener('click', (e) => {
2569+
e.stopPropagation();
2570+
});
25442571

25452572
attribution.appendChild(photographer);
25462573
attribution.appendChild(source);
@@ -2583,21 +2610,9 @@ function RemoteFunctions(config = {}) {
25832610
rowElement.className = 'phoenix-ribbon-row phoenix-ribbon-error';
25842611
},
25852612

2586-
_getPhotographerName: function(image) {
2587-
// unsplash API returns attribution in format 'Photo by <name> on Unsplash'
2588-
// this function is responsible to get the name
2589-
if (image.attribution) {
2590-
const match = image.attribution.match(/Photo by (.+) on Unsplash/);
2591-
if (match) {
2592-
return match[1];
2593-
}
2594-
}
2595-
return 'Anonymous';
2596-
},
2597-
25982613
// file name with which we need to save the image
25992614
_generateFilename: function(image) {
2600-
const photographerName = this._getPhotographerName(image);
2615+
const photographerName = (image.user && image.user.name) || 'Anonymous';
26012616
const searchTerm = this._currentSearchQuery || 'image';
26022617

26032618
// clean the search term and the photograper name to write in file name

0 commit comments

Comments
 (0)