[MediaWiki-l] Getting thumbnails of all images with Javascript

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[MediaWiki-l] Getting thumbnails of all images with Javascript

George, Garrett J. (JSC-CB111)[SGT, INC]
Hey all,

I've been working on image uploading in my Javascript based extension. Although embedding local images after uploading them works fine, there's the use case of wanting to embed images already uploaded to the wiki. I could use the AllImages API and the the url's of all the images but that would be a tremendous amount of network usage compared to a world in which I can simply get the thumbnails. I know the urls exist for the images because you can "copy link address" on the thumbnail when you're viewing the file description page.

So, is there a way, using one of the many MW API's, to get the thumbnail url's for all the images?

Thanks,

Garrett
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Getting thumbnails of all images with Javascript

Huji Lee
Why would you need to get an existing thumbnail? You can always request a
thumbnail and receive one.

Let's take
https://commons.wikimedia.org/wiki/File:Virmalised_18.03.15_(4).jpg as an
example. You can try hard to figure out what thumbnails already exist for
that picture, but why bother? If you want a 197px thumbnail, just embed
https://upload.wikimedia.org/wikipedia/commons/thumb/d/d0/Virmalised_18.03.15_%284%29.jpg
/*197px**-*Virmalised_18.03.15_%284%29.jpg in your code. The part I
highlighted in yellow specifies the size, and the red part is what you add
to the URL to make a thumbnail.

If a thumbnail exists already, it'll be sent to you; if not, one will be
created. In any case, you get a thumbnail of the desired size, and will
save on network traffic.

On Tue, Jan 9, 2018 at 4:36 PM, George, Garrett J. (JSC-CB111)[SGT, INC] <
[hidden email]> wrote:

> Hey all,
>
> I've been working on image uploading in my Javascript based extension.
> Although embedding local images after uploading them works fine, there's
> the use case of wanting to embed images already uploaded to the wiki. I
> could use the AllImages API and the the url's of all the images but that
> would be a tremendous amount of network usage compared to a world in which
> I can simply get the thumbnails. I know the urls exist for the images
> because you can "copy link address" on the thumbnail when you're viewing
> the file description page.
>
> So, is there a way, using one of the many MW API's, to get the thumbnail
> url's for all the images?
>
> Thanks,
>
> Garrett
> _______________________________________________
> MediaWiki-l mailing list
> To unsubscribe, go to:
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Getting thumbnails of all images with Javascript

Brian Wolff
What Huji said is true on Wikimedia, but not most wikis (depends on config
for 404 thumbnailing).

You need to use the imageinfo api query module to get the thumb urls in a
way garunteed to work regardless of wiki config. Im unclear what you mean
by "all images". If you literally mean all images on wiki, then the api
request like
https://commons.wikimedia.org/w/api.php?generator=allimages&action=query&prop=imageinfo&iiurlwidth=500&iiprop=url
is the best you can do (you may want to adjust gailimit parameter)

--
brian

On Tuesday, January 9, 2018, Huji Lee <[hidden email]> wrote:
> Why would you need to get an existing thumbnail? You can always request a
> thumbnail and receive one.
>
> Let's take
> https://commons.wikimedia.org/wiki/File:Virmalised_18.03.15_(4).jpg as an
> example. You can try hard to figure out what thumbnails already exist for
> that picture, but why bother? If you want a 197px thumbnail, just embed
>
https://upload.wikimedia.org/wikipedia/commons/thumb/d/d0/Virmalised_18.03.15_%284%29.jpg

> /*197px**-*Virmalised_18.03.15_%284%29.jpg in your code. The part I
> highlighted in yellow specifies the size, and the red part is what you add
> to the URL to make a thumbnail.
>
> If a thumbnail exists already, it'll be sent to you; if not, one will be
> created. In any case, you get a thumbnail of the desired size, and will
> save on network traffic.
>
> On Tue, Jan 9, 2018 at 4:36 PM, George, Garrett J. (JSC-CB111)[SGT, INC] <
> [hidden email]> wrote:
>
>> Hey all,
>>
>> I've been working on image uploading in my Javascript based extension.
>> Although embedding local images after uploading them works fine, there's
>> the use case of wanting to embed images already uploaded to the wiki. I
>> could use the AllImages API and the the url's of all the images but that
>> would be a tremendous amount of network usage compared to a world in
which

>> I can simply get the thumbnails. I know the urls exist for the images
>> because you can "copy link address" on the thumbnail when you're viewing
>> the file description page.
>>
>> So, is there a way, using one of the many MW API's, to get the thumbnail
>> url's for all the images?
>>
>> Thanks,
>>
>> Garrett
>> _______________________________________________
>> MediaWiki-l mailing list
>> To unsubscribe, go to:
>> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
>>
> _______________________________________________
> MediaWiki-l mailing list
> To unsubscribe, go to:
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l