alanorth / hugo-theme-bootstrap4-blog

A blogging-centric Bootstrap v4 theme for the Hugo static site generator.
Other
204 stars 132 forks source link

Something assumes local images #56

Closed fte378 closed 7 years ago

fte378 commented 7 years ago

With the current commit (81a7431a0a0ed5fd9bfa6e86c45ba60bce76ae19) I get the following error:

ERROR 2017/03/20 18:14:44 Error while rendering "page post/2017/03/photoshoot-inga.md": template: /Users/fte/Sites/photoblog.tegtmeyer.net/themes/hugo-theme-bootstrap4-blog/layouts/_default/baseof.html:14:13: executing "schema-dot-org" at <imageConfig (printf ...>: error calling imageConfig: open /Users/fte/Sites/photoblog.tegtmeyer.net/static/https:/frank.tegtmeyer.tk/img/2017/03/Frank_Tegtmeyer__Portrait_2017_9Xan-730.jpg: no such file or directory

My images are remote (I use Cloudflare for them).

Regards, Frank

fte378 commented 7 years ago

I think the reason is commit 4d7a544dacfe037f5f01a1bc84fb2cbf7cc0cb23

alanorth commented 7 years ago

Shit, you're right. Umm, let me think about how to solve this. Getting the image information is very powerful because it allows us to embed it in the metadata (which Google requires!), but I definitely forgot that images aren't always local!

On Mon, Mar 20, 2017, 19:19 Frank Tegtmeyer notifications@github.com wrote:

With the current commit (81a7431 https://github.com/alanorth/hugo-theme-bootstrap4-blog/commit/81a7431a0a0ed5fd9bfa6e86c45ba60bce76ae19) I get the following error:

ERROR 2017/03/20 18:14:44 Error while rendering "page post/2017/03/ photoshoot-inga.md": template: /Users/fte/Sites/ photoblog.tegtmeyer.net/themes/hugo-theme-bootstrap4-blog/layouts/_default/baseof.html:14:13: executing "schema-dot-org" at <imageConfig (printf ...>: error calling imageConfig: open /Users/fte/Sites/ photoblog.tegtmeyer.net/static/https:/frank.tegtmeyer.tk/img/2017/03/Frank_Tegtmeyer__Portrait_2017_9Xan-730.jpg: no such file or directory

My images are remote (I use Cloudflare for them).

Regards, Frank

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/alanorth/hugo-theme-bootstrap4-blog/issues/56, or mute the thread https://github.com/notifications/unsubscribe-auth/AALtCq3TxONQKMWUekWRyMBFP9pA8hHHks5rnrUfgaJpZM4Mivvy .

--

Alan Orth alan.orth@gmail.com https://englishbulgaria.net https://alaninkenya.org https://mjanja.ch

fte378 commented 7 years ago

For my special case it would be possible to map automatically to the local images. But unfortunately this IS a special case ;-)

alanorth commented 7 years ago

It is perfectly valid to link to external images, say no more! We just need to devise a test of some sort to see if the image is local, perhaps by checking if the src string is relative or has https, etc.

On Mon, Mar 20, 2017, 19:27 Frank Tegtmeyer notifications@github.com wrote:

For my special case it would be possible to map automatically to the local images. But unfortunately this IS a special case ;-)

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/alanorth/hugo-theme-bootstrap4-blog/issues/56#issuecomment-287835029, or mute the thread https://github.com/notifications/unsubscribe-auth/AALtCj6o5G_OpqX541afv9iODVEWZpF8ks5rnrccgaJpZM4Mivvy .

--

Alan Orth alan.orth@gmail.com https://englishbulgaria.net https://alaninkenya.org https://mjanja.ch

alanorth commented 7 years ago

Actually, on second thought (and now that I'm on a computer), In your example above, isn't img/2017/03/Frank_Tegtmeyer__Portrait_2017_9Xan-730.jpg in your Hugo site's static directory? I would expect you'd be using this in the post's metadata:

images = ["/img/2017/03/Frank_Tegtmeyer__Portrait_2017_9Xan-730.jpg"]
fte378 commented 7 years ago

Yes, it's in the static directory. I could use the local version there - I assume this is only loaded when the content is shared? So it would have nearly no impact on performance.

fte378 commented 7 years ago

There is an additional problem: I can't use svg files. They are not supported (their size is variable anyway).

Regards, Frank

alanorth commented 7 years ago

I'm not so worried about the SVG issue, as the bug here only affects images in the post metadata—not in the post content—and you shouldn't be using SVGs there anyways (any robot which uses this metadata is likely expecting only JPGs and PNGs).

In the mean time I will revert the change that is getting the image height/width, and ask on the Hugo discussion forum how to test if a file is local before getting its dimensions.

alanorth commented 7 years ago

Ok, fixed in https://github.com/alanorth/hugo-theme-bootstrap4-blog/commit/d554b6bead78fa33c75f8ec771ab2e74494c783d. Now I check to see if the image parameter from front matter has an http:// or https:// prefix before attempting to get image info. Now everyone can be happy (but you should really just link to local images here). 😄