Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resize preview image in posts? #84

Closed
pat-s opened this issue Jan 3, 2017 · 8 comments
Closed

Resize preview image in posts? #84

pat-s opened this issue Jan 3, 2017 · 8 comments

Comments

@pat-s
Copy link

pat-s commented Jan 3, 2017

Example: "Getting Started" banner in https://gcushen.github.io/hugo-academic-demo/post/getting-started/

Is there a way to resize and center such images? Or are they fixed to full width when specified in the header of a post?

I tried to resize it manually. However, images are always stretched to full page/post width..

+++
date = "2016-04-20T12:00:00"
draft = false
image = "banners/getting-started.png"
+++
@chasgames
Copy link

Works fine for me, you need to do some more customisation 🍮

hugo

@pat-s
Copy link
Author

pat-s commented Jan 3, 2017

Thanks, changing the max.width value in huge-academic.css works. However there are some points why this approach is not that optimal:

  • It changes the core .css of the academic theme
  • All posts are affected by this

It would be nice to just have a variable in the header of each post specifying the width of the image. Is this possible?

@gcushen
Copy link
Collaborator

gcushen commented Jan 3, 2017

The Theme Color (CSS) section at https://gcushen.github.io/hugo-academic-demo/post/getting-started/ explains how to override the CSS style without directly editing Academic's files.

It should be possible to override the CSS in a similar way to Chas mentioned, except editing it so that images appear in their exact size, for example. Then you can control the image dimensions for each post as they can be set to the uploaded image size.

@gcushen gcushen closed this as completed Jan 3, 2017
@pat-s
Copy link
Author

pat-s commented Jan 3, 2017

Thanks for the hints guys. I got it working.

First, create a personal hugo-academic.css in static/css/. Then modify line 109 (referring to the original hugo-academic.css) from the copied huge-academic.css:

img,
video {
  height: auto;
  max-width: 100%;
  display: block;
}

to

video {
  height: auto;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
  display: block;
}

This results in a nicely sized and centered post header image

screenshot at jan 04 00-31-37

@jananiravi
Copy link

@pat-s @gcushen if I had to change the size of the banner images under posts/ or publications/, which ones must I change? I tried adjusting what seemed like an appropriate parameter: max-width but it made little difference. Any suggestions?

I created a copy of academic.css in /static/css/
Thanks!

@crazyhottommy
Copy link

I find I have to modify the css at ./themes/hugo-academic/layouts/partials/css/academic.css
cp the css to static/css/ and then modify does not work for me.

@gcushen
Copy link
Collaborator

gcushen commented Jun 29, 2018

FYI that method is not best practice. Custom styles are documented here: https://sourcethemes.com/academic/docs/customization/#customize-style-css

@samjett247
Copy link

Thank you @pat-s for the awesome answer! Saved me a ton of time :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants