FANDOM


This Forum has been archived

Visit the new Forums
Forums: Index Support Requests Preload image description when uploading
Fandom's forums are a place for the community to help other members.
To contact staff directly or to report bugs, please use Special:Contact.

50px-Replacement filing cabinet.svg

Note: This topic has been unedited for 1932 days. It is considered archived - the discussion is over. Do not add to unless it really needs a response.


Old discussion

Hello, I know the code to preload a default text when someone uses Special:Upload, it's something like:

$(function preloadUploadDesc() {
  if (wgPageName != 'Special:Upload') { return; }
 
  if ($('#wpUploadDescription').length) {
    $('#wpUploadDescription').append('YOUR TEXT HERE');
  }
});

but this will preloaded even when an already existing image is being updated. Is there a way to avoid this? When someone upload a new version the link has &wpForReUpload=1, can be used in the if condition? For example something like if (wgPageName != 'Special:Upload' || wpForReUpload = 1) { return; } will work? leviathan_89 13:42, 31 January, 2012 (UTC)

I think I found the code I wanted:

$(function preloadUploadDesc() {
  if (wgCanonicalSpecialPageName != 'Upload' || wgPageQuery == 'wpForReUpload%3D1') { return; }
 
  if ($('#wpUploadDescription').length) {
    $('#wpUploadDescription').append('YOUR TEXT HERE');
  }
});

If you like it, copy it. leviathan_89 21:58, 31 January, 2012 (UTC)

New Issue

The code I was using:

$(function preloadUploadDesc() {
  if (wgCanonicalSpecialPageName != 'Upload' || wgPageQuery == 'wpForReUpload%3D1') { return; }
 
  if ($('#wpUploadDescription').length) {
    $('#wpUploadDescription').append('TEXT');
  }
});

now add the default text even when updating an image, while it's supposed to not do it in that case. The code was working until my wiki was updated to v. 1.19. Here the code page. leviathan_89 14:42, 7 July, 2012 (UTC)

Have you tried it with $.getUrlVar instead?
$(function preloadUploadDesc() {
  if (wgCanonicalSpecialPageName != 'Upload' || $.getUrlVar('wpForReUpload')) { return; }
 
  if ($('#wpUploadDescription').length) {
    $('#wpUploadDescription').append('TEXT');
  }
});
 pecoes  15:22, July 07, 2012 (UTC) 
That works, thanks! leviathan_89 15:25, 7 July, 2012 (UTC)