Copy heading link to clipboard works only on pages without images


I have issue with “copy-to-clipboard” links on headings. The links (with FA icon) appear only on pages without images. The moment I add an image to the content (as a markdown link), all the copy-to-clipboard links disappear.

I am using Hugo Learn template although I think the definition for the copy-to-clipboard links is made on Hugo side. I could not find related any definitions from the template.

I am using Hugo 0.69.2 on Windows.

Any help is apprecited.

That isn’t a Hugo feature. I suggest you follow the advice at Requesting Help and share your project so someone may assist you. :slight_smile:

It is from the theme:

Apologies, I had read all the files in the Hugo Learn theme (except the Javascript), but could not find a reference there. I am not that fluent with JS/CSS/HTML, just learning.

That’s the theme! Thanks for pointing me to the right direction! :+1:

@maiki I cannot express how thankful I am to you :blush: . I have spend hours and hours trying to debug this while still learning Hugo (my first ever static site generator).

The issue was in the JS file you pointed me at.

I checked browser JS debugger:

So ‘o’ is undefined and gets used. The fix was a two-liner.

var images = $("div#body-inner img").not(".inline");
// Wrap image inside a featherlight (to get a full size view in a popup)
  var image =$(this);
  var o = getUrlParameter(image[0].src);
  if (typeof o !== "undefined") {      // THE FIX
	  var f = o['featherlight'];
	  // IF featherlight is false, do not use feather light
	  if (f != 'false') {
		if (!image.parent("a").length) {
		  return "<a href='" + image[0].src + "' data-featherlight='image'></a>";
        }                                           // THE FIX

Thank you. Highly appreciated.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.