diff --git a/app/models/education/program.rb b/app/models/education/program.rb index a8faccd0c239d0fa839cfd3a8eac2bfe05c86fbc..6ad5acac40869aebe1477f8f466575982efad2f7 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -85,6 +85,13 @@ class Education::Program < ApplicationRecord description.blank? ? parent&.best_description : description end + def best_featured_image(fallback: true) + return featured_image if featured_image.attached? + best_image = parent&.best_featured_image(fallback: false) + best_image ||= featured_image if fallback + best_image + end + # Override from WithGithubFiles def github_path_generated "_programs/#{path}/index.html".gsub(/\/+/, '/') diff --git a/app/views/admin/education/programs/jekyll.html.erb b/app/views/admin/education/programs/jekyll.html.erb index befd6e8be4b810594a82ff64b15707b86dea5a69..6a130379831307ae9b3865e26a6b603d90942520 100644 --- a/app/views/admin/education/programs/jekyll.html.erb +++ b/app/views/admin/education/programs/jekyll.html.erb @@ -7,6 +7,9 @@ continuing: <%= @program.continuing %> level: <%= @program.level %> ects: <%= @program.ects %> position: <%= @program.position %> +<% if @program.best_featured_image.attached? %> +image: "<%= @program.best_featured_image.blob.id %>" +<% end %> <% if @program.teachers.any? %> teachers: <% @program.teachers.each do |teacher| %>