Page MenuHomePhabricator

JPG thumbnail for PDF book in Page Namespace on Gujarati Wikisource loaded twice and the second URL path is a 404 due to missing preceding 0
Closed, InvalidPublic

Description

I have uploaded two book on Wikimedia Commons, File:Baiju Bahavaro.pdf and File:Atmakatha-gandhiji.pdf. The PDF files are visible on Commons.

I have created index page on Gujarati wikisource for both these books સૂચિ:Baiju Bahavaro.pdf and સૂચિ:Atmakatha-gandhiji.pdf

When I open any one page for doing OCR and proof reading. I can not see the PDF image of Page. for example પૃષ્ઠ:Baiju Bahavaro.pdf/૧૦

Event Timeline

Hi @Sushant_savla, thanks for taking the time to report this! Going to https://gu.wikisource.org/w/index.php?title=પૃષ્ઠ:Baiju_Bahavaro.pdf/૮&action=edit&redlink=1&debug=true I can see the image for a short moment, and then the image is gone again.

The moment that the image is shown, its URL is
https://upload.wikimedia.org/wikipedia/commons/thumb/0/05/Baiju_Bahavaro.pdf/page8-1024px-Baiju_Bahavaro.pdf.jpg. That is correct.

However, the reasons I don't know, a bit later the page on gu.wikisource.org tries to load
https://upload.wikimedia.org/wikipedia/commons/thumb/0/5/Baiju_Bahavaro.pdf/page8-1024px-Baiju_Bahavaro.pdf.jpg which is a 404 error.

Note the path difference: 5 vs 05.

I don't know why (which exact code) is loading the image twice, so the tags I am adding here might be wrong.

guws.jpg (990×1 px, 226 KB)

Aklapper renamed this task from PDF Image of Book is not visible in Page Namespace on Gujarati Wikisource to JPG thumbnail for PDF book in Page Namespace on Gujarati Wikisource loaded twice and the second URL path is a 404 due to missing preceding 0.Aug 27 2020, 4:58 PM

On an unrelated note (not related to this bug!): If you follow https://www.mediawiki.org/wiki/Help:Locating_broken_scripts (which is always a good idea) you can see Error: Unknown module: ext.wikiEditor.toolbar. On https://gu.wikisource.org/wiki/મીડિયાવિકિ:Gadgets-definition , the line button-center[ResourceLoader|dependencies=ext.wikiEditor.toolbar|default]|button-center.js is broken and needs fixing by the community.

It appears that the function at the bottom of https://gu.wikisource.org/wiki/MediaWiki:Common.js is causing this problem:

// Script to fix the fraction of PDFHandler
// Copy this code in your User:Username/common.js
$( function(){
	if( mw.config.get('wgCanonicalNamespace') === 'Page' ){
		var file_url = $('.prp-page-image > img').attr("src"),
			rx = /[-+]?([0-9]*\.[0-9]+|[0-9]+)/g;
		
		matches = file_url.match(rx);
		matches.forEach(function(v ,k ){ 
			file_url = file_url.replace(v, Math.trunc(v)); 
		});
		
		$('.prp-page-image > img').attr("src", file_url);
	}
});

This script, called on page load, replaces every number in a thumbnail URL with that number truncated to an integer, which strips leading zeros. It was placed in MediaWiki:Common.js by Sushant salva in this edit. I'm not sure what problem it's trying to solve, so I can't really recommend a fix short of completely removing it.

This script, called on page load, replaces every number in a thumbnail URL with that number truncated to an integer, which strips leading zeros. It was placed in MediaWiki:Common.js by Sushant salva in this edit. I'm not sure what problem it's trying to solve, so I can't really recommend a fix short of completely removing it.

I believe the snippet was an attempt at addressing T242316.

Looks like it. That's been fixed in code, so removing the snippet is the right solution.

On an unrelated note (not related to this bug!): If you follow https://www.mediawiki.org/wiki/Help:Locating_broken_scripts (which is always a good idea) you can see Error: Unknown module: ext.wikiEditor.toolbar. On https://gu.wikisource.org/wiki/મીડિયાવિકિ:Gadgets-definition , the line button-center[ResourceLoader|dependencies=ext.wikiEditor.toolbar|default]|button-center.js is broken and needs fixing by the community.

button-center[ResourceLoader|dependencies=ext.wikiEditor.toolbar|default]|button-center.js needs to be changed to button-center[ResourceLoader|dependencies=ext.wikiEditor|default]|button-center.js for it to work correctly.

Aklapper closed this task as Invalid.EditedAug 27 2020, 7:04 PM

@AntiCompositeNumber: Whou, thanks for finding that!

@Sushant_savla: I'm closing this task as on-wiki content (custom CSS) are local features and managed independently on each wiki.
Phabricator is mostly used for MediaWiki, MediaWiki extensions, or server configuration, or by developers and teams to organize what they plan to work on. If you are looking for help with local code on some wiki, see https://meta.wikimedia.org/wiki/Small_wiki_toolkits#Ask_your_technical_questions instead. Thanks!

Thank you @Soda I have corected the same.
Thank you @Aklapper I will do the needful
Thank you @AntiCompositeNumber
Thank you @Mahir256
Thank you all.