3.35. Saving images in post content
To save the images existing in the post’s content, which is found by the CSS selectors defined in Post Content Selectors, do the following:
- Go to Site Settings Page and activate Post Tab
- Go to Images Section
- Check Save all images in the post content? setting’s checkbox
- Save the site settings (See: Saving The Settings)
After these steps are done, the plugin will save the URLs existing in src attributes of img
elements inside post content and replace the URLs with the ones that point to the images in your
server. For more information, see Save all images in the post content?.
The plugin retrieves URLs in src attributes of img elements. If the image URLs are in
another attribute of img elements, then you can put the URLs into src attribute. To achieve
this, do the following:
Find out in which attribute of
imgelements the actual URLs of the images are stored. You can do this by observing the source code of the target page.Tip
To see the HTML code of an element, write its selector into a setting that is a type of Selector and Attribute Setting and then enter
htmlintoAttributeinput. Next, click to button. The results will show the HTML code of the found elements.For example, go to Post Title Selectors, add another input group by clicking to button, and configure the new input group as follows:
Selector: imgAttribute: htmlNext, click to button to see the HTML code of the found
imgelements. After you are done, remove the input group by clicking to its button.Now, you know the name of the attribute storing the actual image URL. Let’s say it is
data-srcattribute. Now, go to Exchange element attributes setting under Manipulate HTML Section section of Post Tab and configure it as follows:Selector: imgAttribute 1: srcAttribute 2: data-srcIf the name of the attribute is not
data-src, then enter the name you found in the previous step. For more information, see Exchange element attributes.Since the actual image URLs are in
srcattributes, the plugin will be able to save them.
If the images are not shown by using img elements, you can do the following:
Go to Find and replace in HTML at first load setting under under Manipulate HTML Section of Post Tab.
Configure it in a way that it replaces the name of the HTML tag to
img. For example, let’s say the name of the HTML element ismy-imgand it stores the image URL in itssrcattribute. Configure the Find and replace in HTML at first load setting as follows:Find: <my-imgReplace: <imgIf the element has a closing tag as well, add another input group by clicking to button and configure the new input group as follows:
Find: </my-img>Replace: </img>Now, the plugin will be able to save the images since they are shown in
imgelements’srcattributes.
If the images are stored in an HTML element other than img and in an attribute other than
src, you can use the settings under Manipulate HTML Section to turn them into img
elements and/or put the image URLs into src attributes.
Note
You might ask why this guide does not explain directly getting the images from elements
other than img and from attributes other than src. This is because the browsers
display images by using img elements’ src attributes. You can save the images without
turning the elements into img elements or without turning the attributes into src,
but the images will not be shown in your post pages since the browsers will not be able to
understand they are actually images.