How do I Link to Images in User Module

Ken Sturgeon

Active Member
Messages
172
I have a commentary that I converted from epub to HTML that I've turned into a user book module. There are several images in an image folder; the associated links in the html source manifest as follows:
HTML:
<img src="images/00004.jpeg" alt="" class="calibre2" />

I created a folder called BBC-Assets that corresponds to the module name BBC.ss5book and copied all of the images to the assets folder. I then changed the links as follows:
HTML:
<img src="BBC-Assets/00004.jpeg" alt="" class="calibre2" />
Unfortunately I still didn't see the images after recreating the module with Forge.

I then think that perhaps I don't need to include the assets folder so I change the links to point directly to the links:
HTML:
<img src="00004.jpeg" alt="" class="calibre2" />
...no dice.

Next I tried
HTML:
<img src="ssimage|:00004.jpeg" alt="" class="calibre2" />
...no dice. Then
HTML:
<img src="ssimageBBC|:00004.jpeg" alt="" class="calibre2" />
... :confused:

Can anyone tell me how to successfully link to the images in the assets folder from a user book?

Thank you very much.
Ken
 
I have a test module with an asset folder called 33test-Assets and the code below pulled an image from there and put it in my module. I used this exact code, I didn't substitute "33test-Assets" where it says "{ModuleAssets}" - {ModuleAssets} is the code for 'look in the module name-Assets folder', so it can be used with any folder. My particular image name is "illus17.png" - that's the only code you need to change - put your image filename there. Oh, and my images are not in a folder called "images" within the assets folder. The images are just in the assets folder a natural.

<IMG src="file:///{ModuleAssets}/illus17.png">

So your code would look like this: <IMG src="file:///{ModuleAssets}/00004.jpg">
 
Last edited:
Thanks for the info Bill. I'll have to play with it some. It was long ago that I converted the commentary I was working with. The headers were easily identifiable so I ended up with an entry in the book's drop down list for every section by adding "$$ NN - " before each header name which lines up to the book's table of contents.
 
Update to the Calibre procedure previously posted above.

Calibre offers an interesting way to convert books without DRM (digital rights management?) to modules. If the books are copyrighted you should not share them. Calibre is a free library management tool here: https://calibre-ebook.com/

Here's the updated process for Calibre.
1. In Swordsearcher create a new user book called newbook (your choice of name)
2. Create a module assets folder in the SS user directory - i.e. newbook-Assets making sure the book name is exactly the same as step1
3. Using Calibre, convert the book to HTMLZ format
4. Save the conversion to and empty temporary folder (like c:\temp). The HTMLZ file extension may need to be changed to ZIP in order to unzip it.
5. Unzip the file. You will see something like this:
1544926217753.png

6. Move all the image files from the images directory in the temporary folder to the moduleassets folder (the individual files, not the images folder itself)
7. Move the other files to the moduleassets folder (cover.jpg, index.html, metadata.opf, style.css)
8. Open SS and edit the new module.
9. Add a topic. There will only be one topic. I usually name this _Contents but use anything you like.
10. Use a good text editor like notepad++ (free by the way - https://notepad-plus-plus.org/)
11. In the first line change href="style.css"
to href="file:///{moduleassets}/style.css"
Do a global change FROM img src="images
TO img src="file:///{moduleassets}
12. Copy everything in the edited index.html file into the _Contents topic !!!!USING THE HTML EDITOR!!!!
13. Save the new module in SS
14. Everything should work ;).
15. If the Bible references in the module are hard coded to go to the web, you may have to edit those by hand or with a global change in order for SS to recognize them.
16. If you need to start over, you still have a copy of index.html in the zip file. Go to step 4.
17. If this didn't make sense, ignore 1-16
 
hahahaahahaha... I love line 17 Bill, in this case, I'll ignore line 17 rather than lines 1-16. It's all quite clear and I really do thank you for posting it. I suspect others will benefit from it also.

Thank you very much.
Ken
 
Back
Top