Is it possible to position image title/caption above the image in Asciidoctor - asciidoc

Currently, all image caption I have used are automatically placed before an image, despite me placing the caption before the image in the code.
For example,
[caption=]
.Simple diagram of data storage
image::user-guide/data-storage.png[width="600"]
Is there any way I can re-position the caption such that it appears above/before the image like how table titles are positioned above a table?

I assume you're using the standard HTML5 output of Asciidoctor. This can't be parameterized; the HTML will always render first the image and then the title element.
You could override the rendering of images in the HTML5 backend, or create your own backend to structure the output as you need.

In addition to #ahus1's answer, you might be able to achieve the presentation you desire by applying a custom stylesheet via docinfo files. See https://asciidoctor.org/docs/user-manual/#docinfo-file

Related

Liquid Pixels check source image mime type

unfortunately, I cannot tag this post with the correct "technology" because it does not exist and i dont have 1500 reputation to create it.
We are using a cloud service called "Liquid Pixels" to render some stuff on our images.
Lets say we have an image chain that is currently rendering a ribbon on the given JPEG image. This chain is working fine.
Then I adapted the chain to work with animated gif images, therefore I changed the sink format to gif (sink=format[gif]). That was working fine as well.
Now I want to combine the two cases in one chain, because the only difference is the sink command. The plan is to check the MIME type of the source image and then either render a gif or a jpg image.
I rendered the image as xml to view the metadata map.
I thought i can do it like this.
source=url[https://something.com/1x1_sample.gif],name[testImage]
sink=format[gif],if[('testImage.format' eq 'GIF')]
sink=format[jpg],if[('testImage.format' ne 'GIF’)]
But for some reason I cannot access the format attribute. I am used to grab some parameters like “testImage.width” or “testImage.height”, but for some reason i cannot access the format=“GIF” property. I guess that has happens because the width and height are on a different hierarchy level in the metadata map.
I hope you guys can help me.
The image does not actually have a "format" during the render. Only a file has a format. During processing the image is simply on memory as either raster or vector data; it is only when you sink that it becomes a file in whatever format. Also, LiquiFire OS uses the image data to determine the original format when acquiring an image from a source, never the image name itself.
If you need operations in your LiquiFire Image Chain to react to the source image URL, you can test the last part of the image name by applying a regular expression to see if it is either .GIF or .gif. An example of how that can be done:
set=imageURL[https://your.server.com/sample.gif]
source=url[global.imageURL],name[testImage]
regexcase=name[isGif],key[global.imageURL],cases[\.gif$|\.GIF$|\.\w+$],values[yes|yes|no]
sink=format[gif],if[('global.isGif' eq 'yes')]
sink=format[jpg],if[('global.isGif' eq 'no’)]

How to control the size of image attachments in a NSTextView

By default, in a NSTextView, image attachments are displayed at their actual resolution. For large images, this results in having only a small portion of the image displayed in the view. This doesn't look good and the user has to do lots of scrolling to enter text after the image.
For example, in the window below, you can't tell much about the image in the text view.
So the question is: how to scale down image attachments, so that they fit in the NSTextView?
You can find a few solutions for this on the internet, based on subclassing NSTextAttachmentCell, but by doing so, you lose a number of good behaviors provided for free by the NSTextView, like the creation of annotations in an attached image.
Actually there is a much simpler solution: to use a NSLayoutManager property named defaultAttachmentScaling that does exactly what we want.
In your code, set this property as in:
myTextView.layoutManager.defaultAttachmentScaling = NSImageScaleProportionallyDown;
and this is it: large images are now scaled to match the width of the text view.
For detailed information on this property, I suggest you read the comments in the header file NSLayoutManager.h.
Note for iOS developers: unfortunately, this property is not available on iOS.

Drupal resize image on the fly

Is it possible to resize images on the fly and cache the result with Drupal?
I have some big images (e.g. 2000x2000px) and I want to display a preview of the e.g. 100x100px.
I know there is a theme_image_style function. But it seams to only create the <img> with the right size and not effectively resize the image.
I look at modules/images/image.admin.inc and they used the function [image_style_create_derivative][2].
Yes, you should use Drupal's Image styles (Configuration -> Media -> Image styles). There you should create your style.
Then, on front-end, when ever you want to display image with that style (in that resolution) you can use image_style_url() function:
https://api.drupal.org/api/drupal/modules!image!image.module/function/image_style_url/7
It accepts 2 parameters - one is image style machine name and other is image URI, which you can get if you print out all image field properties.
You can also select image styles from back-end interface...i.e. when creating a view for some image you can select to be displayed in specific image style.
In both cases those image styles are generated the first time image is used.
In response to your comment on MilanG's answer, using image_style_url() is the best option on the backend. There is also
https://www.drupal.org/project/resp_img
which may be something worth looking into. From a UX perspective, you don't want to force the user to load a 2000x2000 px image every time they load the page. Regardless of the outputted size, the image is still going to render as a 2000x2000 px image with a large size. image_style_url() or using image styles in the GUI create a new file that will load much quicker and is the preferred method.

Flash / Actionscript: How to insert images in dynamic text (In line image)?

I want to insert images in dynamic-text-box(s) which should be inline.
Detail:
I am preparing an application using flash CS4; The application is just like a chat room which will show conversation the only difference in this; it will show stored messages (stored in XML file). I want to insert smiling faces (emotions) in text body (using html tags) but the problem is that image is not inline (like in chat room [yahoo, hotmail, etc.]).
I have no idea what to do......
Please paste your code where you set the dynamic-text-box.text
Make sure that you wrap the whole text in html braces, not only images.
You can embed images in any HTMLText field using the tag.
The image, however, must be loaded externally. You can't get images stored in your library.
Its good to get the solution of my problem but sad I got solution by myself :-P
The simplest solution I got is, to update my Flash CS4 to Flash CS6; in Flash CS6 text (TextField) have extra feature like TLF (Text Layout Framework). By use TLF I can insert graphics in text area and inserted graphics are inline as well.
Problem Solved :-)

How to auto generate custom image sizes

I got strange behaviour when I added filter for attachment_fields_to_save, when I save the images, it does not want to save image metadata such as title, description and caption.
Why I need to add this filter? Because I have lots of custom sizes using this code:
add_image_size("imagesize-940x360", 940, 360, true);
And the image may not correctly put in good place, so the user need to use Wordpress awesome tools to edit the image like cropping and scaling.
For some silly reason (or perhaps this is bug), the Wordpress does not generate image for custom image sizes.
In order to achieve generation for custom sizes, I need to add filter when user press save button in the Wordpress image editor. Here is the piece code that I been using:
add_filter("attachment_fields_to_save", "rl_regenerate_image", 99, 2);
function rl_regenerate_image($post, $attachment)
{
$id = $post['ID'];
$fullsizepath = get_attached_file($id);
wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $fullsizepath));
return true;
}
The code above generates the custom sizes when user edit the image correctly but sadly it does not save all updated metadata images such as title, caption and description.
Do you guys know how to solve this problem? So what I would like to achieve is how to generate "edited" images for custom sizes and save the metadata correctly.
Thanks in advance!
In case this hasn't been solved yet, or for any Googler's out there.. Here's a plugin called Post Thumbnail Editor that lets you edit individual custom image sizes. Works well.
http://wordpress.org/extend/plugins/post-thumbnail-editor/

Resources