Whats the best way to insert a list of images at once?

I have a long list of image 01, 02 , 03 etc… and I want them to be inserted in succession in a text file. When I drop them on the text file they just get pasted on top of each other in a mess. Also its generally annoying to use as the images jump around and create huge spaces, sometimes they jump above a paragraph or something. See video attached:

https://imgur.com/a/7BbKy8d

What is the best way to do this?

For inserting imges I’d recommend to read about anchoring as character first.

I don’t know the “best” way, but I like the creation of a report: I redirect a DIR or ls (or output of exiftool to a .csv-file, wich is a registered datasource for a .odb-file Database. A query lists all files and a report all images. Save the report as Writer-document.
Disadvantage: The reports are tables. So imho not recommended for several hundred of pictures.
.
Simple demo in

If you click Tools - Options - LibreOffice Writer - Formatting Aids you can change the default anchor to As Character.

If you then drag some images onto the page, they will be placed one after another.

I don’t see this option here

It seems the default setting is set to “As Character”

I don’t know what the vertical “to Character” does

Also, when I move the image, it does not snap to the border, see:

https://imgur.com/a/15o2BGK

What option do I have to enable to make the images respect the borders?

As far as the macros, I think I could place the 100 images or so manually faster than I could learn how to do any of that.

It seems that as long as I don’t move the image with the mouse (drag and drop) then it should stay in place and behave like a character. As soon as I move it just once, then im screwed since it gets out of the “grid” of the characters.

https://imgur.com/a/SnbxanV

Check again: you have al and como caracter in your language, wgat should be in english at and as character.
The first three are anchored at, but can be positioned relative to the anchor. We use anchored to paragraph usually for illustrations in books to keep them moving with the text, if something is inserted.
.
As character places the the image in the text as a big letter. So try the “como”-setting.

Yeah I just realized. Now it behaves more as I would expect.
Is there a way to make it the default?

First update your LibreOffice (es. link). Not sure in which version the option was added (I’m now with 24.8).

LibreOffice 7.1 (Release Notes)

2 Likes

I was able to insert as many images I wanted now but the problem is they get inserted in the inverted order. For instance, you have 1.png, 2.png, 3.png…

What happens is, Writter drops in like this:

3.png
2.png
1.png

When it should be like this:

1.png
2.png
3.png

How do you fix this?

I had this recently for attachments in Thunderbird on Windows. I had to change/correct the sorting in the dialogue to select the files, wich is an instance of MS-file-explorer. May help also in your case.

1 Like
For i = UBound(aList) To LBound(aList) step -1
   InsertImage(aList(i,0))
1 Like

What dialogue? I don’t get it. Also, how do you select multiple images within Writer?

I have no idea what to do with that.

At least with version 25.2, isn’t possible.

In my case: The dialogue to select attachments in Thunderbird. What I had to realize: This dialogue is an instance of the Windows explorer and was affected by settings for folders I
did in Windows directly.
I don’t know how you select your files for drag and drop, but settings in an explorer window may influence the sorting of your filenames.
.
If you do manual selection you may be forced to select in reversed order…

a macro can do that, as discussed here Créer des cadres pour les images ou les aligner ou faire les deux et plus en même temps - #6 by fpy
for Writer :

const Height = 2000
const Width = 3000
Dim curr as Object
' ________________________
Sub pickFolder
  oFolderPicker = CreateUnoService( "com.sun.star.ui.dialogs.FolderPicker" )
  oFolderPicker.setTitle("Pick directory with images (Ask 122435)")
'  oFolderPicker.setDisplayDirectory( "file:///tmp/" )
  If oFolderPicker.execute() = 1 Then insertImagesFromFolder(oFolderPicker.getDirectory())
End sub

Sub insertImagesFromFolder(sFolder as String)
  Globalscope.BasicLibraries.LoadLibrary("Tools")
  aList = ReadDirectories(sFolder, True, False, False) 
  curr = thisComponent.CurrentController.getViewCursor()
 
  For i = LBound(aList) To UBound(aList)
   InsertImage(aList(i,0))
  next i
End sub

Sub InsertImage(sURL as String)

    oGraph = thisComponent.createInstance("com.sun.star.drawing.GraphicObjectShape")
    oGraph.Graphic = getgraphfromurlaslink(sURL)
    oGraph.GraphicURL = sURL
    oGraph.AnchorType = com.sun.star.text.TextContentAnchorType.AS_CHARACTER

   oSize = oGraph.Size
    oSize.Height = Height
    oSize.Width = Width
    oGraph.setsize(oSize)
 
   curr.Text.insertTextContent(curr, oGraph, False)
   
   ThisComponent.Text.insertControlCharacter(curr, _
     com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
End sub

function getGraphFromUrlAsLink(sFileUrl as String ) as Object 
  oProvider = createUnoService("com.sun.star.graphic.GraphicProvider") 
  Dim oPropsIN(1)as new com.sun.star.beans.PropertyValue 
  oPropsIN(0).Name  = "URL" 
  oPropsIN(0).Value = converttoURL(sFileUrl)
  oPropsIN(1).Name  = "LoadAsLink" 
  oPropsIN(1).Value = TRUE
  getGraphFromUrlAsLink = oProvider.queryGraphic(oPropsIN()) 
end function

yep

oGraph.AnchorType = com.sun.star.text.TextContentAnchorType.AS_CHARACTER
1 Like