January 29, 2019

Adding photos to journal and news posts

Okay, so let's put some pics in your posts!

The basic code is ‹img src="https://www.website.com/imagename.jpg"›

img = image
src = source

Now if you have images on iNat that you'd like to use, you need the path the particular photo (not to the observation). So, I've chosen a random ob https://www.inaturalist.org/observations/19800494 to work with. All photos used in this post are by Tannie Di @outramps - she asked so nicely for some help :-)

STEP ONE - locating an image on iNat
RIGHT-CLICK on the image you want to use in your journal post, LEFT-CLICK on Copy image location. We'll use the first image as example. Then on your journal post, add the text ‹img scr=" and then PASTE the location you copied from your image - in this case https://static.inaturalist.org/photos/30519569/large.jpeg?1548163737, then type "› so it looks like this ‹img src="https://static.inaturalist.org/photos/30519569/large.jpeg?1548163737"›

That's one image and it will be the width of the journal post box, like so:

STEP TWO - locating an image not on iNat
To link to an image that's on the internet but not on iNat, you use the same method above. The image must be yours or you must have permission to use it and credit the photographer/illustrator (this is true for iNat pics as well, of course!!). The image has to be on the internet, not on your hard disk.

STEP THREE - images in rows
Now, if you want to add, say, 3 pics in a row, you need to add a bit of extra code to stipulate the width of each pic. We'll use percent rather than specific width so that it looks good on different screen sizes (hopefully). So, the extra code is style="width:33%" which will give you 3 pics in a row. If you want 2 pics then you'd use 50% etc.

So our code for 3 pics in a row looks like this ‹img src="https://static.inaturalist.org/photos/30519569/large.jpeg?1548163737" style="width:33%"› and it looks like this (using the same pic):

Of course you'd want to use 3 different pics, so you copy the image location for each one as in Step 1, for example:
‹img src="https://static.inaturalist.org/photos/30519569/large.jpeg?1548163737" style="width:33%"›‹img src="https://static.inaturalist.org/photos/28828589/large.jpeg?1543914495" style="width:33%"›‹img src="https://static.inaturalist.org/photos/14337452/large.jpeg?1521637401" style="width:33%"›
and you can end up with something like this:

STEP FOUR - adding spaces between pics in rows
Now, the pics are all 'stuck together', which is not a bad thing, but you might want to have some 'breathing space' between them, so you need to add a bit of code to the style attribute - padding:10px; - so your code for each image now looks like this - ‹img src="https://static.inaturalist.org/photos/30519569/large.jpeg?1548163737" style="width:33%; padding:10px;"› and the pics look like this:

You can change the width of the space between the pics as you choose. I have used 10 pixels here, but you can use less (~ 5px) or more (~ 20px). Play with it and see what works for you and a the particular post you're creating.

STEP FIVE - Advanced resizing
(Only go here if you're feeling brave.)
In the above example the pics are all different sizes and you may want them the same height without squishing them widthways. For this you have to stipulate max-height and max-width. The max-width can remain a percentage, but the max-height has to be an actual pixel height which is where things can go a bit wobbly. So, to get the max-height you'll have to play around with pixel sizes until you get what you're looking for. Change the size and then check in PREVIEW how it's going to look. If it's not right, increase or decrease the number of pixels. For this example I have used 200px - style="max-width:33%; max-height:200px; padding:10px;" and it looks like this:

The original pics have to have a height of greater than your max-height to end up the same height on your post using this method. If the original pics are smaller, then you will end up with a row of pics of different heights anyway. This is very advanced stuff, so if you've got here, well done, and you can go and have a coffee now ;-)

{I typed this up very quickly, so if I have not been clear, or you have any suggestions for improvement, please let me know!}

Posted on January 29, 2019 08:57 by karoopixie karoopixie | 9 comments | Leave a comment