Discussion:
[Docutils-users] Naive question about the image directive
Chris Green
2017-01-21 18:52:30 UTC
Permalink
This may be rather a silly question but at the moment I can't get the
image directive to do anything useful for me.

The documentation shows the syntax as:-

.. image:: picture.png

and says: "The URI for the image source file is specified in the
directive argument."

So, does that picture.png have to be a full URI or what? ... and
where will the picture.png file be exactly?

All I can do at the moment is get to see the text "picture.png".
--
Chris Green

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Docutils-users mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply to the list.
log4yes
2017-01-22 01:58:55 UTC
Permalink
You can use relative path from your source file to the image, or full
uri(url). Make sure the path is correct.

Some more info will help:
1. How do you generate the output? e.g. rst2html, online editor, github
or blog using rst?
2. Is there some error/warning?
Post by Chris Green
This may be rather a silly question but at the moment I can't get the
image directive to do anything useful for me.
The documentation shows the syntax as:-
.. image:: picture.png
and says: "The URI for the image source file is specified in the
directive argument."
So, does that picture.png have to be a full URI or what? ... and
where will the picture.png file be exactly?
All I can do at the moment is get to see the text "picture.png".
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Docutils-users mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to repl
Chris Green
2017-01-22 11:47:05 UTC
Permalink
Post by log4yes
Post by Chris Green
This may be rather a silly question but at the moment I can't get the
image directive to do anything useful for me.
The documentation shows the syntax as:-
.. image:: picture.png
and says: "The URI for the image source file is specified in the
directive argument."
So, does that picture.png have to be a full URI or what? ... and
where will the picture.png file be exactly?
All I can do at the moment is get to see the text "picture.png".
You can use relative path from your source file to the image, or full
uri(url). Make sure the path is correct.
So what appears above as "picture.png" should actually be:-

Loading Image...

(fictional address but that's the idea)

...or for a relative address:-

../../pictures/picture.png

(or something like that, does it need anything more?)
Post by log4yes
1. How do you generate the output? e.g. rst2html, online editor, github
or blog using rst?
I'm using rst2html.
Post by log4yes
2. Is there some error/warning?
Not that I can see. It's being run from PHP with stderr being
redirected to a file, that file is zero length (but does exist) so I
don't think there are any errors being reported.


Thank you.
--
Chris Green
Guenter Milde
2017-01-22 21:46:13 UTC
Permalink
Post by Chris Green
Post by log4yes
Post by Chris Green
This may be rather a silly question but at the moment I can't get the
image directive to do anything useful for me.
The documentation shows the syntax as:-
.. image:: picture.png
and says: "The URI for the image source file is specified in the
directive argument."
So, does that picture.png have to be a full URI or what? ... and
where will the picture.png file be exactly?
There has to be a file at the location pointed to by the URI.
If the URI is picture.png, this means a file picture.png in the same
direcory as the generated document.
Post by Chris Green
So what appears above as "picture.png" should actually be:-
http://server.mylan/pictures/picture.png
This would work for any document that can access this URI (provided it
points to a valid image file).
Post by Chris Green
I'm using rst2html.
Post by log4yes
2. Is there some error/warning?
Not that I can see. It's being run from PHP with stderr being
redirected to a file, that file is zero length (but does exist) so I
don't think there are any errors being reported.
When generating HTML and not giving options that require a look at the image
(scaling, ...), the URI is not checked during the process.

Günter


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Docutils-users mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to re
Chris Green
2017-01-22 22:08:13 UTC
Permalink
Post by Guenter Milde
Post by Chris Green
Post by log4yes
Post by Chris Green
This may be rather a silly question but at the moment I can't get the
image directive to do anything useful for me.
The documentation shows the syntax as:-
.. image:: picture.png
and says: "The URI for the image source file is specified in the
directive argument."
So, does that picture.png have to be a full URI or what? ... and
where will the picture.png file be exactly?
There has to be a file at the location pointed to by the URI.
If the URI is picture.png, this means a file picture.png in the same
direcory as the generated document.
Post by Chris Green
So what appears above as "picture.png" should actually be:-
http://server.mylan/pictures/picture.png
This would work for any document that can access this URI (provided it
points to a valid image file).
Post by Chris Green
I'm using rst2html.
Post by log4yes
2. Is there some error/warning?
Not that I can see. It's being run from PHP with stderr being
redirected to a file, that file is zero length (but does exist) so I
don't think there are any errors being reported.
When generating HTML and not giving options that require a look at the image
(scaling, ...), the URI is not checked during the process.
Günter
OK, thanks, I'll try a bit more.
--
Chris Green

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Docutils-users mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please
Chris Green
2017-01-23 15:58:29 UTC
Permalink
Post by Chris Green
OK, thanks, I'll try a bit more.
OK, I've been trying some more! :-)

I can get the following to work:-

.. image:: Loading Image...


I can't get anything like this to work at all:-

.. image:: DSCF6584.JPG

(yes, I have copied the JPG file to the directory where the rst text is)


The code it generates is:-

<img alt="DSCF6584.JPG" src="DSCF6584.JPG" />

which is sort of alright except that, presumably, the web server
(apache2) can't actually find the image with just that as the address.
I guess the problem is down to the fact that the page is generated
dynamically.
--
Chris Green

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Docutils-users mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply to the list.
Roberto Alsina
2017-01-23 16:02:59 UTC
Permalink
If you are going to use relative URLs, they need to be relative to where
the HTML page resides, not to where the rst text is.

So, if your page ends at http://foo.bar/boo/this.html with a relative URL
to the image of "DSCF6584.JPG" then the image better be available at
Loading Image... or it will not work.
Post by Chris Green
Post by Chris Green
OK, thanks, I'll try a bit more.
OK, I've been trying some more! :-)
I can get the following to work:-
.. image:: http://esprimo/mandyFlat/DSCF6584.JPG
I can't get anything like this to work at all:-
.. image:: DSCF6584.JPG
(yes, I have copied the JPG file to the directory where the rst text is)
The code it generates is:-
<img alt="DSCF6584.JPG" src="DSCF6584.JPG" />
which is sort of alright except that, presumably, the web server
(apache2) can't actually find the image with just that as the address.
I guess the problem is down to the fact that the page is generated
dynamically.
--
Chris Green
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Docutils-users mailing list
https://lists.sourceforge.net/lists/listinfo/docutils-users
Please use "Reply All" to reply to the list.
Chris Green
2017-01-23 17:50:43 UTC
Permalink
Post by Roberto Alsina
If you are going to use relative URLs, they need to be relative to
where the HTML page resides, not to where the rst text is.
So, if your page ends at [1]http://foo.bar/boo/this.html with a
relative URL to the image of "DSCF6584.JPG" then the image better be
available at [2]http://foo/bar/boo/DSCF6584.JPG or it will not work.
Unfortunately my HTML doesn't reside anywhere, it's generated by
rst2html and eaten by a PHP script. That's what I meant by it being
generated 'dynamically'.

I think basically there's no practical way to use relative URIs in my
situation, they'll have to be absolute.
--
Chris Green

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Docutils-users mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply to the list.
Guenter Milde
2017-01-23 21:04:47 UTC
Permalink
Post by Chris Green
Post by Roberto Alsina
If you are going to use relative URLs, they need to be relative to
where the HTML page resides, not to where the rst text is.
So, if your page ends at [1]http://foo.bar/boo/this.html with a
relative URL to the image of "DSCF6584.JPG" then the image better be
available at [2]http://foo/bar/boo/DSCF6584.JPG or it will not work.
Unfortunately my HTML doesn't reside anywhere, it's generated by
rst2html and eaten by a PHP script. That's what I meant by it being
generated 'dynamically'.
For the viewing browser, it should make no difference whether it is static
or dynamic: if you can view the generated HTML document under
http://example.org/this/is/a/dynamic/path/mydoc.html or
http://example.org/this/is/a/dynamic/path/mydoc.php,
a relative URL should be relative to http://example.org/this/is/a/dynamic/path/
Post by Chris Green
I think basically there's no practical way to use relative URIs in my
situation, they'll have to be absolute.
Indeed, absolute URIs seem to be the most practical solution for your problem.

Günter

Continue reading on narkive:
Loading...