On Saturday, May 30, 2020 at 5:11:15 PM UTC+2, Jake wrote:
 

> But if I want to use it without class (e.g. if i need to move certain icon 
> a bit more up or down) and use the common html/css syntax - it doesn't work.
>

It does, if you define the minor changes within the tiddler body. ... BUT 
this is bad practice and will probably bite you in the future. 
 

> That means that this 'style' code does nothing to the image:
>
> [img style="height: 1em; position: relative; top=0.2em" [
> https://www.mediawiki.org/static/favicon/mediawiki.ico]] Sample 2
>

As I wrote, hardcoding styles may bite you in the future! But if you need 
to: this is the code to use, if you want to overwrite the global height 
setting. 

<style>.icon {height:3em;}</style>

[img class="icon" [https://www.mediawiki.org/static/favicon/mediawiki.ico]]

*Be aware*, that the hardcoded <style> directive is active for the whole 
page. So all open tiddlers will be effected as long as the tiddler is 
visible. To avoid this, you'll need to define a unique class-name for 
"special settings".

--------------------------- IMO better practice!

If you need to change settings for all your images, it will be better to 
create your own image macro. eg: 

[img[xx]] is a shortcut for: <img src="""xxx""">

So your macro can look as the following code. Create a new tiddler eg: myMacros 
and tag it: $:/tags/Macro so it will be a global macro

\define image(url, class, height)
<img class="$class$" style="height:$height$" src="""$url$""">
\end

usage will look like this:

<<image "https://www.mediawiki.org/static/favicon/mediawiki.ico"; 
height:"3em">>

<<image "https://www.mediawiki.org/static/favicon/mediawiki.ico"; class:icon 
height:"2em">>


Info about macros can be found at: 
https://tiddlywiki.com/#Macros%20in%20WikiText:%5B%5BMacros%20in%20WikiText%5D%5D%20%5B%5BMacro%20Definitions%20in%20WikiText%5D%5D%20%5B%5BMacro%20Calls%20in%20WikiText%5D%5D

have fun!
mario

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/ea81072d-08cf-442f-9d25-67f1ac07d420%40googlegroups.com.

Reply via email to