MediaWiki: Parameters for external images - external

I'm trying to set some parameters (e.g. size, alignment) for external images on my MediaWiki.
I have both $wgAllowExternalImages and $wgAllowImageTag set to true, but it still doesn't work. Trying
[[Image:https://upload.wikimedia.org/wikipedia/commons/a/a0/Sega-Genesis-Model2-32X.jpg|50px]]
or
[[File:Sega-Genesis-Model2-32X.jpg|link=https://upload.wikimedia.org/wikipedia/commons/a/a0|caption]]
doesn't work.
Just displaying images, without setting any parameters, works by https://upload.wikimedia.org/wikipedia/commons/a/a0/Sega-Genesis-Model2-32X.jpg.
However, everything works with internal images.
Sources: Help:Images - MediaWiki

Your use case is an image on Wikimedia Commons, which is not an external image but an image from a foreign repo. Just enable InstantCommons (and make sure your thumbnailer is configured, of course).
$wgUseInstantCommons = true;
Then use the image as a local one:
[[Image:Sega-Genesis-Model2-32X.jpg|50px]]

Related

can't specify image path inside js file

I am trying to import image from 'images' folder inside 'home.js' file which is inside components folder. I tried many combinations of '../' and './', but image doesn't load on page. There is probably something wrong with a path.
Since you are using React, did you check if the component is even being rendered to the view at all?
Additional factor could be your applied classes 'home-wrapper' or 'backImg'
I usually add some placeholder text to check if it pops up.
Regarding to Omars answer, that's right you would only need to go back two directories to access that image, like so
<img src="../../images/astronaut.png" alt="astronaut"/>
When you provide a relative URL, it has to go from the URL of the HTML to the URL of the image.
You are trying to go from the file path of the JavaScript file to the file path of the image.
Since the image is not in the public directory, it is quite likely that the image doesn't even have a URL in the first place.
There are two basic approaches you can use to determine the URL here.
Manually
You need to put the image somewhere it has a URL.
How you do this will depend on the HTTP server you are using. You will need to ensure that the image has the same URL (or at least one relative to the HTML document) in both your development and production environments.
For example, you could put it in the public directory, then say src="public/images/yourimage.jpeg". (Note that I'm making assumptions about how your development server allocates URLs to files in the public directory here).
Use your bundler
Typically when using React (as you appear to be doing) you will use a tool like Webpack to generate a production ready version of the site. This will do things like removing slow debugging routines, tree shaking to remove code from modules that isn't being used, and so on.
Webpack has features for handling images so once you set up the configuration file to support it, you can then do:
import MyImage from '../../../images/yourimage.jpeg';
and
<img src={MyImage} alt="etc etc" />
Note that the path here is relative to the JS file and that you need to use {} to assign a variable's value to src.
The correct syntax in react is:
import astronaut from '../images/astronaut.png';
<img src={astronaut} alt="logo" />

Add/Change default images in Sparx EA HTML report

I'm new to Sparx EA (Currently running 14.2 and 15.2), and really like the HTML report, which we host on SharePoint to serve to customers. However, AFTER running the HTML report, I go into the created html folder and make modifications to files, which include: Modifying the index.html to replace the ea.png file to display two logos; one on the left AND one on the right, Modify the ea.css file to modify the iframe sizes to accommodate the larger sizes of my two logos. I also change the header background image to an image that completely fills the header iframe.
This serves us just fine, but does require and handful of manual changes to the html before posting.
I've only just discovered the ability to select a manually created "style" templates! However, I'm unable to resolve a couple issues that I would like to be able to resolve without manually manipulating the html after creation.
How can I include referenced images, either from the file system OR the image library?
For example: in the Page-Index template, the image source is #HEADER_IMAGE#, this (of course) is resolved from the "Header Image:" prompt in the "Publish as HTML. However, if I would like to use a logo that is in my image library, can I overwrite the "#HEADER_IMAGE# with something to the effect of "#IMAGES#/myLogo.png"? And to also have that logo file included in the images folder of the generated HTML report? Ideally, as I have two logos, one automatically works by the "#HEADER_IMAGE# then other by "images/Logo2.png" is there a way to define a "#HEADER_IMAGE_2#" that would allow me to reference that second logo, and work like the original "#HEADER_IMAGE#"
I would also like to change the CSS-MAIN .IndexHeader background-image: url(../images.hgb.gif) again, to an image I have in either a file on my file system or one from my image library in Sparx.
In my testing of this, I'm able to make the references as "images/logo1" , etc. but then I have to manually move the file into the images folder as sparx does not do so (though it does a great job on doing so with the #HEADER_IMAGE#)!
Appreciate any assistance on this.

importImages.php is not moving all the files into the correct subdirectory

We have a wiki that was brought back from the dead using a torrent image archive of 32gb+ (that's compressed).
We ran importImages. That created sub-directories, probably from the image paths of the wiki articles.
Well, we have a lot of images not loading correctly (white space).
Turns out the importImages did not move all the images into their correct subdirecotires.
When you look up the image, it will have the expected sub directory i.e. images/1/1a/hello.jpg
But, the actual file is still in images/hello.jpg.
If you try to reupload the image using the single file uploader, it gives you an overwrite warning, ignoring this warning corrects the image, and stores it in the right subdirectory. But we have 200k+ images, and you cannot overwrite images using uploadWizard.
Is there a way to fix this? A parameter we can run, or a way to set all image paths to use just .../images/?
We are using version 1.35.1
Perhaps, $wgHashedUploadDirectory or $wgLocalFileRepo is not set correctly on LocalSettings.php. If this is not the case, try to launch importImages.php with --overwrite option.

Have to put files in static_dir but need to read them afterwards

I just started using google app engine. In order to use templates, I'm using jinja2.
I want to add images dynamically after I set the width and height of the img tag. I used
PIL in order to read the image size and put the one I want.
However when I open the image with PIL, I need it not to be in a static_dir
and to put the image in the img tag, I need it to be in the static_dir.
As a testing solution I've copied the folder to see if I get results and I did. But as
you can see having each image saved twice is kind of bad.
If you want the file to be both static (served fast by not having to pass through your app) and available to the app, note the application_reabable option in the description of static file handler patterns. It does want you want without you having to duplicate files.

Unusual issue with HTML image and 'file://' specified src

I'm loading an image on the page with a 'file:///some_dir/image.jpg' src path. I can access the image in a regular tab using this path. Also, saving the page as HTML and using this path for the image works. However, the image does not load on the live page. In chrome it shows part of the alt text, and in firefox it shows a narrow strip. I have tried changing width and height but to no avail. Is there something I'm missing?
<img title="Click to enlarge" src="file:///Users/Aram/uploads/profile.image.985b0f707d972bf3.4372696242656464696e67616e645465657468696e67437269625261696c436f7665722e6a7067.jpg" class="profile-image">
EDIT:
I noticed I am getting this in the console:
Not allowed to load local resource
Is there any way around this?
EDIT 2:
Since I could not access the image through an http path, I have decided to read it in as base64 data. For anyone else using web2py or another Python framework:
# Load the image data
import os
path = os.path.join(request.folder, 'uploads', filename)
data_uri = open(path, 'rb').read().encode('base64').replace('\n', '')
data = 'data:image/png;base64,%s' % data_uri
return html.IMG( _src=data, _class='profile-image', _title='Click to enlarge' )
Websites are not allowed to use local files on the user's computer. Use a relative path to from the html file's directory.
You can also encode and embed the image directly:
How to embed the encoded stuff: http://www.sweeting.org/mark/blog/2005/07/12/base64-encoded-images-embedded-in-html
Python Encoding Instructions: http://www.daniweb.com/software-development/python/code/216635
The problem is you are trying to load a file directly off of a clients computer. Browsers prevent this.
You can read about the exact details here:
http://en.wikipedia.org/wiki/Same_origin_policy
It is called the Origin Policy. It prevents malicious sites from directly loading files off of a clients computer. Try using a relative path from your page to display the image.
In some situations (rare) I've used a light web server to host the site so that I could load the files from the server (as opposed to having it load off of what the browser sees, as a clients computer).