Fandom

Community Central

Preload image description when uploading

Forum page

19,041pages on
this wiki
Add New Page
Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

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.
Note: This topic has been unedited for 1608 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)

Also on Fandom

Random Wiki