Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure directives #15

Open
thedrow opened this issue Jun 8, 2020 · 10 comments
Open

Figure directives #15

thedrow opened this issue Jun 8, 2020 · 10 comments
Labels
enhancement New feature or request

Comments

@thedrow
Copy link

thedrow commented Jun 8, 2020

Can we add support for figure directives as well as image directives?

@jonascj
Copy link
Collaborator

jonascj commented Jun 8, 2020

Could you elaborate a little?

There is the numfig configuration option which adds numbers to all "figures", tables etc. if they have a caption.

There is also the figure directive.

Do you just wish the lightbox2 css applied to images inserted/loaded through the figure: whatever.jpg directive?

@thedrow
Copy link
Author

thedrow commented Jun 9, 2020

Do you just wish the lightbox2 css applied to images inserted/loaded through the figure: whatever.jpg directive?

Yes.

@jonascj
Copy link
Collaborator

jonascj commented Jun 9, 2020

Great idea, I could easily have wished for that myself in the past. Feel free to implement it and make a PR, otherwise I'll have a look at it a few weeks from now.

@jonascj jonascj added the enhancement New feature or request label Jun 9, 2020
@jonascj
Copy link
Collaborator

jonascj commented Aug 20, 2020

How time flies when you have a baby and a 3-year-old! Please accept my apologies for not attending to the PRs and issues in a timely fashion. I'll attend to them at the latest on August 29th and 30th (I have another project with deadline on August 28th).

@icq8680
Copy link

icq8680 commented Sep 9, 2020

@jonascj I think the main concern of adding lightbox to figures is that lightbox label does not have a translatable text, i.e. if you add a caption to your LB image, you won't be able to translate the phrase

@SilverRainZ
Copy link

Any news?

@jonascj
Copy link
Collaborator

jonascj commented Jan 6, 2021

@SilverRainZ No, I haven't looked into it yet. You are welcome to submit a PR if you can find a way to implement it. See also #20 :-)

@jonascj
Copy link
Collaborator

jonascj commented Jul 28, 2021

Some findings and/or realizations which might be worth remembering, going forward with this:

  • Typical HTML markup for a figure (after building):
<figure class="align-default" id="id1">                                         
    <span id="some-fig-label"></span>                                               
    <img  alt="_images/python.png" src="_images/python.png" />
    <figcaption>                                                                    
    <p>
        <span class="caption-number">Fig. 1 </span>
        <span class="caption-text">The Python logo.</span>
        <a class="headerlink" href="#id    1" title="Permalink to this image">¶</a>
    </p>          
    </figcaption>                                                                   
</figure>

All that is needed to turn this into a lightbox2 image is to wrap the <img>
tag in <a data-lightbox="[unique id]" data-title="The Python logo." href="_images/python.png">.

  • EDIT: At present neither .. image:: nor .. thumbnail:: directives can have a label and be referenced. The reason being neither have a title or caption associated with them. So if referenced what should the reference show? Fig. <num> is not meaningful since it has no number. The Python logo is not meaningful either since it has no title.

At present .. thumbnail:: can not be referenced in any way (afaik). Adding an explicit target above a thumbnail directive will result in a warning, i.e. this will not work with thumbnails (but it works with .. image::):

.. _target whatever:

.. thumbnail:: whatever.jpg

An image of whatever can be seen here: :ref:`Whatever <target whatever>`.
  • There seem to be two somewhat equivalent objectives / solutions: 1) Make the .. thumbnail:: directive numbered so it can be referenced, 2) Wrap the .. figure:: directive's <img> tag in a lightbox link (see above).

@thedrow
Copy link
Author

thedrow commented Jul 29, 2021

I don't see why thumbnails shouldn't have a unique id. It can be a random id if it is just for this purpose.

@jonascj
Copy link
Collaborator

jonascj commented Jul 30, 2021

#27 Indicates there is currently no way of referencing .. thumbnail:: directives, explicit targets do not work (see above or #27). That is a bug imo and we should at least fix that.

At the same time I think we should make the .. thumbnail:: directive behave like .. figure::, if numfig = True thumbnails should be numbered just as figures (maybe with a sphinxcontrib.images configuration option to turn on/off this feature). I suppose it could be done two ways: 1) Utilize the figure directive when producing thumbnails, 2) create/register a counter with the .. thumbnail:: directive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants