Page 1 of 1

Problem with alt tags in author view

Posted: Thu Aug 15, 2013 7:19 pm
by dagoss
I have a lengthy manual with a lot of inlinemediaobject's. I'd like to add alt tags for this. I've noticed an annoying thing in Oxygen however. When I add an alt tag to an inlinemediaobject element, the alt text causes a linebreak in author mode and the tag appears on its own line. Since these appear in the middle of paragraphs (and there are so many of them), it makes reviewing text in author mode kind of annoying.

Is there a way to change this behavior, so that the alt tag doesn't add linebreaks in author mode (or is just not displayed)?

Re: Problem with alt tags in author view

Posted: Fri Aug 16, 2013 10:09 am
by alex_jitianu
Hello,

The culprit is this rule from {oxygenInstallDir}/frameworks/docbook/css/docbook.css which marks the element as being a block:

Code: Select all


alt {
display:block;
font-size:small;
background-color:#FFFFEE;
color:inherit;
text-align:center;
}
What you have to do is edit this rule and replace the display property to either display:inline or display:none. I'm not sure why we marked the alt element as being a block... I'll add an issue for us to also change the default so that it doesn't break the text flow.

Best regards,
Alex

Re: Problem with alt tags in author view

Posted: Fri Aug 16, 2013 5:22 pm
by dagoss
Thank you--that's exactly the setting I was looking for. And thanks for pointing me to those css files. I wasn't aware how customizable the author view is!

Re: Problem with alt tags in author view

Posted: Wed Oct 23, 2013 8:53 am
by Radu
Hi,

Just to update this thread, in Oxygen 15.1 the <alt> element is usually styled as an inline element thus not breaking the flow of text.

Regards,
Radu

Re: Problem with alt tags in author view

Posted: Mon Feb 02, 2015 7:58 am
by Eddie
Hello,

I've noticed that this (or something very similar) is back in 16.1.

I'm putting alt elements for images and I've noticed that, if I specify a width attribute for the image, that seems to affect the line width for the alt text in Author view. As a result, in the case of narrow images (such as a toolbar button), I end up with alt text consisting of one word per line in English and one character per line in Japanese.

As the OP mentioned, it makes for difficult reading.

I had a look at the css mentioned above. It says:

Code: Select all

alt {
display:inline;
font-size:small;
background-color:#FFFFEE;
color:inherit;
}
so I assume that's OK.

Any other way round this (besides not setting a width attribute)?

And by the way, in the previous setting in the css, I noticed this:

Code: Select all

equation,
informalequaion {
display:block;
margin: 1em 0.5em;
}
Just wondering if that missing "t" is significant.


Cheers,
Eddie.

Re: Problem with alt tags in author view

Posted: Mon Feb 02, 2015 11:49 am
by Radu
Hi Eddie,

So you are using Docbook 5, right? And what version of Oxygen are you using?

The informalequaion you found in the CSS is indeed a typo and we'll fix it.
If you are not using informal equations it probably is not related to your problem.
Could you paste a small XML fragment with your <mediaobject> image reference and the way in which you specify the width on the image? Also maybe give us a screenshot? You can also contact us using support@oxygenxml.com directly.
I tried to reproduce the issue using an image reference like:

Code: Select all

                        <mediaobject>
<alt>THIS IS long text</alt>
<imageobject>
<imagedata fileref="images/drive-properties.jpg"
width="100"/>
</imageobject>
</mediaobject>
but for me the alternate text width was larger than the displayed image width.

Regards,
Radu

Re: Problem with alt tags in author view

Posted: Tue Feb 03, 2015 2:52 am
by Eddie
Hello,

I'm not using DocBook, just Author 16.1. We have an in-house PDF/HTML output tool that requires image height and width specs. These are set with the standard DITA height and width attributes, like this:

Code: Select all

<choice>ツールバーの<image href="../images/insert-comment.gif" height="29" width="31">
<alt>コメントの追加ボタン</alt>
</image>をクリックします。</choice>

Code: Select all

<choice>Click this button <image href="file:insert-comment.gif" height="29" width="31"> 
<alt>Image of Insert Comment toolbar button</alt>
</image>on the toolbar.</choice>
I'll send a couple of example images.

Eddie.

Re: Problem with alt tags in author view

Posted: Tue Feb 03, 2015 2:59 am
by Eddie
Apologies - I've now realised why you asked me about DocBook!

I found this thread by googling for Author and alt tags and so I didn't realise it was posted under DocBook.

Sorry,

Eddie.

Re: Problem with alt tags in author view

Posted: Tue Feb 03, 2015 9:25 am
by Radu
Hi Eddie,

Thanks for the screenshots, I now understand the problem and I understand you are using DITA.
Indeed the CSS used to style DITA content for visual editing looks at the width attribute set on the image and enforces the width on the entire image element, meaning also the <alt> element inside the image. I added an issue for this on our issues list in order to see how we could handle this better from the CSS.
In the meantime if you open the CSS:

OXYGEN_INSTALL_DIR\frameworks\dita\css_classed\topic.css

it has inside it two selectors:

Code: Select all

*[class~="topic/image"]{
content: attr(href, url);
}
*[class~="topic/image"][placement="inline"] {
display: inline;
width:attr(width, length);
height:attr(height, length);
}
which you could comment out and replace with:

Code: Select all

*[class~="topic/image"]:before{
content: attr(href, url);
}
*[class~="topic/image"][placement="inline"]:before {
display: inline;
width:attr(width, length);
height:attr(height, length);
}
in order to avoid setting the width on the entire image element.

Regards,
Radu

Re: Problem with alt tags in author view

Posted: Wed Feb 04, 2015 4:45 am
by Eddie
Hello,

Thanks for the answer and the workaround - it works fine.

FYI: I noticed while messing around with the settings that, if "placement" is set to "break", the "width" and "height" settings are ignored when displayed in Author. (Whereas, if "placement" is set to "inline", the image is resized according to the "width" and "height" settings.)

Cheers,

Eddie.

Re: Problem with alt tags in author view

Posted: Wed Feb 04, 2015 9:13 am
by Radu
Hi Eddie,

You are right.
You should try to split the selector I gave you:

Code: Select all

*[class~="topic/image"][placement="inline"]:before {
display: inline;
width:attr(width, length);
height:attr(height, length);
}
in two like:

Code: Select all

*[class~="topic/image"]:before {
width:attr(width, length);
height:attr(height, length);
}
*[class~="topic/image"][placement="inline"] {
display: inline;
}
so that the width and height attributes apply no matter if the image placement is inline or break.

Regards,
Radu

Re: Problem with alt tags in author view

Posted: Thu Feb 05, 2015 5:27 am
by Eddie
Hello,

I tried that, but it hides all the images in Author view (regardless of "placement" setting).

Cheers,

Eddie

Re: Problem with alt tags in author view

Posted: Thu Feb 05, 2015 9:23 am
by Radu
Hi Eddie,

Sorry about this, on the image:before selector you should also have the image reference like:

Code: Select all

*[class~="topic/image"]:before {
width:attr(width, length);
height:attr(height, length);
content: attr(href, url);
}
The trick is to try and show the image before the <image> element and to impose the width limitations only on that before pseudo content so that other elements inside the <image> element like <alt> can have plentry of display space available.

Regards,
Radu

Re: Problem with alt tags in author view

Posted: Fri Feb 06, 2015 4:32 am
by Eddie
Hello again,

Many thanks. That works fine.

Cheers,

Eddie.