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

All svg images in page are resized to 1.2em high #3690

Closed
schplurtz opened this issue Jun 14, 2022 · 11 comments
Closed

All svg images in page are resized to 1.2em high #3690

schplurtz opened this issue Jun 14, 2022 · 11 comments

Comments

@schplurtz
Copy link
Contributor

Hi,

b43eead forces svg heigth to 1.2em by adding this CSS rule to lib/styles/all.css

svg {
    width: auto;
    height: 1.2em;
}

The problem is that all SVG images wherever they come from are resized to 1.2em high. This is a problem with the a2s plugin for example. The as2 plugin generates images like this :

<svg class="a2s media" width="721px" height="944px" viewBox="0 0 721 944" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <!-- Created with ASCIIToSVG (https://github.com/dhobsd/asciitosvg/) -->
Image content here.
</svg>

Yet, the svg is resized to 1.2em high.
image

In the case of the a2s plugin, I can of course add a css rule svg.a2s { height: auto } in he plugin style files, but I'm wondering if it should be fixed there or more generally in DokuWiki.

@splitbrain
Copy link
Collaborator

I think this guardian makes sense and so far I haven't heard of any plugins breaking because of it. So I would like to keep it. So yes, please add the custom height for your plugin's SVGs to the plugin's style file.

@schplurtz
Copy link
Contributor Author

All right. Thanks for the answer.

schplurtz pushed a commit to schplurtz/a2s that referenced this issue Jun 20, 2022
@schplurtz
Copy link
Contributor Author

Just 2 thoughts before I go to bed

  1. no one complains, but as of june 2022, b43eead is still in dev branch, so very few people have it installed.
  2. If someone uses <HTML><svg>.... in a wiki page, the image gets resized to 1.2em. The solution is to add a style="height:auto" attribute. Like this:
<HTML>
<svg height="300" width="300" viewBox="0 0 300 300" style="height:auto">
  <circle cx="150" cy="150" r="135" fill="red" />
  <text x="55" y="175" fill="#000" style="font-size:2cm">Circle</text>
</svg>
</HTML>

@jdehaan
Copy link

jdehaan commented Jul 20, 2022

I use a vendor lib to render svgs and have no direct control upon the attributes/style for the svg tag. The latest release candidate shows up trouble with the svg style which makes all diagrams cut-off.

This is the extension: https://www.dokuwiki.org/plugin:bpmnio

@splitbrain
Copy link
Collaborator

@jdehaan Of course you have control. Your plugin's style will be more specific than the default setting. In your case it's as easy as adding the following to your styles:

.bjs-container svg {
    height: 100%;
    width: 100%;
}

Though preferably you would set your own class on the wrapper (something like plugin-bpmnio) instead of relying on the class set by the vendor script.

@jdehaan
Copy link

jdehaan commented Jul 21, 2022

You are fully right (🤦🏻‍♂️) I could manage to arrange the stuff accordingly... As you have seen I am not a css master. Thanks for the precise hint!

@arlt
Copy link

arlt commented Aug 5, 2022

I think this guardian makes sense and so far I haven't heard of any plugins breaking because of it. So I would like to keep it. So yes, please add the custom height for your plugin's SVGs to the plugin's style file.

@splitbrain

Here is (another) one: jakob1111/dokuwiki-plugin-flowcharts#27

Yes, the plugins could fix this but in my opinion there is no real reason to set the default height for all svg images to 1.2em.. This is a problem for all plugins which render svg images. Maybe using a class toolbar or icon would be a better idea.

The response of plugin authors is rather slow, if at all.

DarkWizarD24 added a commit to DarkWizarD24/dokuwiki-plugin-achart that referenced this issue Aug 8, 2022
Hogfather add a default height fot the SVG elements. We need to override it accordingly to dokuwiki/dokuwiki#3690
splitbrain added a commit to cosmocode/dokuwiki-plugin-switchpanel that referenced this issue Aug 24, 2022
@gerardnico
Copy link
Contributor

I got also this problem for the combo svg element

I don't understand why this is made a global default.
It made no sense at all.
All svg have already default internal dimensions with the width and height attributes.
(Icon does, ...)

DokuWiki should also have its own namespace by applying a class to not leak this kind of rule.
This rule is for an icon.

svg.dokuwiki-icon {
    width: auto;
    height: 1.2em;
}

It will just break all svg plugins.
I don't understand the positive here.

@zeerd
Copy link

zeerd commented Aug 29, 2023

Me, too. I had to modify this lib/styles/all.css from 1.2em to auto manually to make my wiki working. It terrible.

@schplurtz
Copy link
Contributor Author

@zeerd, modifying lib/styles/all.css is not the best way to go, as your modifications will be lost on next upgrade. You should use conf/userstyle.css to override the defaults. See user styles on dokuwiki.org.

Although it appears that this setting has brought its lot of troubles, and maybe, was not the wisest thing to do, that's the way it is now and we have to deal with it. I wouldn't just override or remove the general setting, but instead add specialized rules targeted at the elements that are having issue. If you need help, you're always welcome to ask on DokuWiki forum.

@gerardnico
Copy link
Contributor

we have to deal with it

I'm so sorry for you.

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

No branches or pull requests

6 participants