MarkTraceur has submitted this change and it was merged.

Change subject: Fix uploading multiple images with same title from Flickr
......................................................................


Fix uploading multiple images with same title from Flickr

When an image is identified with same title in a set, generate a
unique name using the title and id.

Bug: 43320
Change-Id: If1b7af30a8daf84be0d5b388c8f37e0595145675
---
M resources/mw.FlickrChecker.js
1 file changed, 11 insertions(+), 3 deletions(-)

Approvals:
  Yuvipanda: Verified
  MarkTraceur: Looks good to me, approved
  jenkins-bot: Checked



diff --git a/resources/mw.FlickrChecker.js b/resources/mw.FlickrChecker.js
index 568e2e7..68cbef8 100644
--- a/resources/mw.FlickrChecker.js
+++ b/resources/mw.FlickrChecker.js
@@ -85,10 +85,18 @@
                                                if ( x < 50 ) {
                                                        var license = 
_this.checkLicense( item.license, i );
                                                        var licenseValue = 
license.licenseValue;
+                                                       var sameTitleExists = 
false;
                                                        if ( licenseValue !== 
'invalid' ) {
-                                                               // if the photo 
is untitled, generate a title
-                                                               if ( item.title 
=== '' ) {
-                                                                       
fileName = item.ownername + '-' + item.id + '.jpg';
+
+                                                               $.each( 
_this.imageUploads, function ( index, image ) {
+                                                                       if ( 
image.name === item.title + '.jpg' ) {
+                                                                               
sameTitleExists = true;
+                                                                               
return false; // Break out of the loop
+                                                                       }
+                                                               } );
+                                                               // if the photo 
is untitled or a same title exists, generate a title
+                                                               if ( item.title 
=== '' || sameTitleExists ) {
+                                                                       
fileName = item.title + ' - ' + item.id + '.jpg';
                                                                } else {
                                                                        
fileName = item.title + '.jpg';
                                                                }

-- 
To view, visit https://gerrit.wikimedia.org/r/42775
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If1b7af30a8daf84be0d5b388c8f37e0595145675
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Nischayn22 <nischay...@gmail.com>
Gerrit-Reviewer: Alex Monk <kren...@gmail.com>
Gerrit-Reviewer: Kaldari <rkald...@wikimedia.org>
Gerrit-Reviewer: MarkTraceur <mtrac...@member.fsf.org>
Gerrit-Reviewer: Nischayn22 <nischay...@gmail.com>
Gerrit-Reviewer: Yuvipanda <yuvipa...@gmail.com>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to