diff --git a/addons/website/models/mixins.py b/addons/website/models/mixins.py index a473ab51def5f93aafe5413ff657b48712403ff1..a2866dc7a8665a6648a7aa6702c16c23e7d86154 100644 --- a/addons/website/models/mixins.py +++ b/addons/website/models/mixins.py @@ -42,9 +42,9 @@ class SeoMetadata(models.AbstractModel): if 'name' in self: title = '%s | %s' % (self.name, title) if request.website.social_default_image: - img = '/web/image/website/%s/social_default_image' % request.website.id + img = request.website.image_url(request.website, 'social_default_image') else: - img = '/web/image/res.company/%s/logo' % company.id + img = request.website.image_url(company, 'logo') # Default meta for OpenGraph default_opengraph = { 'og:type': 'website', diff --git a/addons/website/views/website_templates.xml b/addons/website/views/website_templates.xml index 3025d7276cb05206e168d1e183cde707d94e5329..3b9979c712b17b0ceb70184af7ca5367aeda2023 100644 --- a/addons/website/views/website_templates.xml +++ b/addons/website/views/website_templates.xml @@ -185,7 +185,7 @@ <t t-set="title" t-value="default_title"></t> </t> </t> - <t t-set="x_icon" t-value="'/web/image/website/%s/favicon/' % website.id"/> + <t t-set="x_icon" t-value="website.image_url(website, 'favicon')"/> </xpath> <xpath expr="//head/meta[last()]" position="after"> <meta name="generator" content="Odoo"/> diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index 6d20822b89d6c9a0ae90b66bcfadb1d1104b584c..9fa910dbb7c7877db48408632e0fcd3081b50888 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -417,7 +417,7 @@ class Post(models.Model): res = super(Post, self)._default_website_meta() res['default_opengraph']['og:title'] = res['default_twitter']['twitter:title'] = self.name res['default_opengraph']['og:description'] = res['default_twitter']['twitter:description'] = self.plain_content - res['default_opengraph']['og:image'] = res['default_twitter']['twitter:image'] = "/web/image/res.users/%s/image_1024" % (self.create_uid.id) + res['default_opengraph']['og:image'] = res['default_twitter']['twitter:image'] = self.env['website'].image_url(self.create_uid, 'image_1024') res['default_twitter']['twitter:card'] = 'summary' res['default_meta_description'] = self.plain_content return res diff --git a/addons/website_forum/views/website_forum.xml b/addons/website_forum/views/website_forum.xml index 15ad892fa10b020159a29d0f4d3895977363660e..7cdedbec5e4a14d00435528b796e284861ac1ac8 100644 --- a/addons/website_forum/views/website_forum.xml +++ b/addons/website_forum/views/website_forum.xml @@ -73,7 +73,7 @@ <div class="card bg-secondary" t-if="question"> <h6 class="card-header"><b>Writer</b></h6> <div class="card-body o_card_people"> - <img class="o_wforum_people_photo_container d-block mx-auto mb-3" t-attf-src="/web/image/res.users/#{question.create_uid.id}/image_128"/> + <img class="o_wforum_people_photo_container d-block mx-auto mb-3" t-att-src="website.image_url(question.create_uid, 'image_128')"/> <h6 class="text-center"> <b><i class="fa fa-diamond text-secondary"/> <t t-esc="question.create_uid.sudo().karma"/></b> <b><a t-attf-href="/forum/#{slug(forum)}/user/#{question.create_uid.sudo().id}" t-field="question.create_uid" t-options='{"widget": "contact", "fields": ["name", "country_id"]}'/></b> @@ -399,7 +399,7 @@ <div class="card-img-bottom embed-responsive embed-responsive-16by9 o_wforum_forum_card_bg"> <div t-if="forum.image_256" class="oe_img_bg embed-responsive-item" - t-attf-style="background-image: url(/web/image/forum.forum/#{forum.id}/image_256); background-position: center;"/> + t-attf-style="background-image: url(#{website.image_url(forum, 'image_256')}); background-position: center;"/> </div> </div> </a> @@ -913,7 +913,7 @@ <t t-call="website_forum.forum_user_tooltip"/> </div> <a t-att-href="user_profile_url" class="o_forum_user_info"> - <img class="float-left o_forum_avatar" t-attf-src="/web/image/res.users/#{answer.create_uid.id}/image_128" alt="Avatar"/> + <img class="float-left o_forum_avatar" t-att-src="website.image_url(answer.create_uid, 'image_128')" alt="Avatar"/> </a> <a t-att-href="user_profile_url" t-field="answer.create_uid" @@ -969,7 +969,7 @@ <div class="o_forum_user_bio text-left card"> <div class="card-body"> <a t-att-href="user_profile_url"> - <img class="float-left img rounded o_forum_avatar_big" t-attf-src="/web/image/res.users/#{answer.create_uid.id}/image_128" alt="Avatar"/> + <img class="float-left img rounded o_forum_avatar_big" t-att-src="website.image_url(answer.create_uid, 'image_128')" alt="Avatar"/> </a> <div class="o_forum_tooltip_header"> <h4 class="o_forum_tooltip_heading"><a t-att-href="user_profile_url" @@ -1126,7 +1126,7 @@ <input type="checkbox" t-att-value="user.id" class="custom-control-input" t-attf-id="user_#{user.id}"/> <label class="custom-control-label" t-attf-for="user_#{user.id}"> <div class="col-11 d-inline-flex"> - <img class="d-inline img o_forum_avatar" t-attf-src="/web/image/res.users/#{user.id}/image_128" alt="Avatar"/> + <img class="d-inline img o_forum_avatar" t-att-src="website.image_url(user, 'image_128')" alt="Avatar"/> <b t-esc="user.name" class="d-inline"></b> </div> </label> diff --git a/addons/website_profile/views/website_profile.xml b/addons/website_profile/views/website_profile.xml index b5470a833a9ab343b01bd6e4e1fc07a9fb5fa692..17d19333f38994c72ffccc369cfca23ad56d7e84 100644 --- a/addons/website_profile/views/website_profile.xml +++ b/addons/website_profile/views/website_profile.xml @@ -104,7 +104,7 @@ <div class="col-3"> <div class="card o_card_people"> <div class="card-body"> - <img class="o_forum_avatar_img w-100 mb-3" t-attf-src="/web/image/res.users/#{user.id}/image_128"/> + <img class="o_forum_avatar_img w-100 mb-3" t-att-src="website.image_url(user, 'image_128')"/> <div class="text-center"> <a href="#" class="o_forum_profile_pic_edit btn btn-primary" aria-label="Edit"> <i class="fa fa-pencil fa-1g float-sm-none float-md-left" title="Edit"></i> @@ -206,7 +206,7 @@ <!-- ==== Header Left ==== --> <div class="col-12 col-md-4 col-lg-3"> <div t-attf-class="d-flex align-items-start h-100 #{'justify-content-between' if (request.env.user == user) else 'justify-content-around' }"> - <div class="o_wprofile_pict d-inline-block mb-3 mb-md-0" t-attf-style="background-image:url(/web/image/res.users/#{user.id}/image_1024)"/> + <div class="o_wprofile_pict d-inline-block mb-3 mb-md-0" t-attf-style="background-image: url(#{website.image_url(user, 'image_1024')});"/> <a class="btn btn-primary d-inline-block d-md-none" t-if="request.env.user == user and user.karma != 0" t-attf-href="/profile/edit?url_param=#{edit_button_url_param}"> <i class="fa fa-pencil mr-1"/>EDIT </a> @@ -252,7 +252,7 @@ <div class="o_wprofile_sidebar_top d-flex justify-content-between"> <div t-if="user.rank_id" class="d-flex align-items-center"> <small class="font-weight-bold mr-2">Current rank:</small> - <img t-attf-src="/web/image/gamification.karma.rank/#{user.rank_id.id}/image_64" height="16" alt="" class="mr-1"/> + <img t-att-src="website.image_url(user.rank_id, 'image_64')" height="16" alt="" class="mr-1"/> <a href="/profile/ranks_badges" t-field="user.rank_id"/> </div> <button class="btn btn-sm d-md-none bg-white border" type="button" data-toggle="collapse" data-target="#o_wprofile_sidebar_collapse" aria-expanded="false" aria-controls="o_wprofile_sidebar_collapse">More info</button> @@ -341,7 +341,7 @@ </svg> <div class="o_pc_overlay d-flex flex-column align-items-center justify-content-center"> <img class="img-fluid" - t-attf-src="/web/image/gamification.karma.rank/#{next_rank_id.id if next_rank_id else user.rank_id.id}/image_128" + t-att-src="website.image_url(next_rank_id if next_rank_id else user.rank_id, 'image_128')" t-att-alt="(next_rank_id.name if next_rank_id else user.rank_id.name) + ' badge'" t-att-style="'max-width: ' + (img_max_width if img_max_width else '50%;')"/> <h4 class=" mb-0"> @@ -367,7 +367,7 @@ <div class="card"> <div class="card-body p-2 pr-3"> <div class="media align-items-center"> - <img height="38" t-attf-src="/web/image/gamification.badge/#{badge.badge_id.id}/image_64" class="mr-0"/> + <img height="38" t-att-src="website.image_url(badge.badge_id, 'image_64')" class="mr-0"/> <div class="media-body col-md-10 p-0"> <h6 class="my-0 text-truncate" t-field="badge.badge_id.name"/> </div> @@ -406,7 +406,7 @@ <t t-foreach="ranks" t-as="rank"> <li t-attf-class="list-group-item"> <div class="media align-items-center"> - <img width="40" t-attf-src="/web/image/gamification.karma.rank/#{rank.id}/image_64" class="mr-2" alt="Rank badge"/> + <img width="40" t-att-src="website.image_url(rank, 'image_64')" class="mr-2" alt="Rank badge"/> <div class="media-body"> <h5 class="mt-0 mb-0" t-field="rank.name"/> <span class="badge badge-success"><span t-field="rank.karma_min"/></span> point<span t-if="rank.karma_min">s</span> @@ -439,7 +439,7 @@ <td class="align-middle"> <img t-if="not badge.image_1920 and badge.level" t-attf-src="/website_profile/static/src/img/badge_#{badge.level}.svg" class="my-1" style="height:2.5em" t-att-alt="badge.name"/> - <img t-else="" t-attf-src="/web/image/gamification.badge/#{badge.id}/image_1024" class="my-1" style="height:2.5em" t-att-alt="badge.name"/> + <img t-else="" t-att-src="website.image_url(badge, 'image_1024')" class="my-1" style="height:2.5em" t-att-alt="badge.name"/> <h6 t-field="badge.name" class="d-inline my-0"/> </td> <td class="align-middle d-none d-md-table-cell"> diff --git a/addons/website_sale/models/product.py b/addons/website_sale/models/product.py index f50336eb3810d7a58c9fdba0fd1ed99b055a4d57..5ff7890914c5fa34485c001e1b19b548634b7223 100644 --- a/addons/website_sale/models/product.py +++ b/addons/website_sale/models/product.py @@ -361,7 +361,7 @@ class ProductTemplate(models.Model): res = super(ProductTemplate, self)._default_website_meta() res['default_opengraph']['og:description'] = res['default_twitter']['twitter:description'] = self.description_sale res['default_opengraph']['og:title'] = res['default_twitter']['twitter:title'] = self.name - res['default_opengraph']['og:image'] = res['default_twitter']['twitter:image'] = "/web/image/product.template/%s/image_1024" % (self.id) + res['default_opengraph']['og:image'] = res['default_twitter']['twitter:image'] = self.env['website'].image_url(self, 'image_1024') res['default_meta_description'] = self.description_sale return res diff --git a/addons/website_sale_comparison/views/website_sale_comparison_template.xml b/addons/website_sale_comparison/views/website_sale_comparison_template.xml index 15dd18b4c2e2a8a11f2601a3f3618ef36d2f949b..20f579ff108d70a41b40c1f7eaf4b6987614d160 100644 --- a/addons/website_sale_comparison/views/website_sale_comparison_template.xml +++ b/addons/website_sale_comparison/views/website_sale_comparison_template.xml @@ -143,7 +143,7 @@ <t t-set="combination_info" t-value="product._get_combination_info_variant()"/> <div class="row no-gutters align-items-center mt-2 o_product_row" t-att-data-category_ids="product.public_categ_ids.ids"> <div class="col-3"> - <img class="img img-fluid" t-attf-src="/web/image/product.product/#{product.id}/image_64" style="max-height: 50px;" alt="Product image"/> + <img class="img img-fluid" t-att-src="website.image_url(product, 'image_64')" style="max-height: 50px;" alt="Product image"/> </div> <div class="col-8 pl-2"> <h6> diff --git a/addons/website_slides/models/slide_slide.py b/addons/website_slides/models/slide_slide.py index 2cc0e8396169245c882173a0b752b74f4aaae16e..493b908dde466594fdb3b7a722cf1adf5c631e1e 100644 --- a/addons/website_slides/models/slide_slide.py +++ b/addons/website_slides/models/slide_slide.py @@ -676,6 +676,6 @@ class Slide(models.Model): res = super(Slide, self)._default_website_meta() res['default_opengraph']['og:title'] = res['default_twitter']['twitter:title'] = self.name res['default_opengraph']['og:description'] = res['default_twitter']['twitter:description'] = self.description - res['default_opengraph']['og:image'] = res['default_twitter']['twitter:image'] = "/web/image/slide.slide/%s/image_1024" % (self.id) + res['default_opengraph']['og:image'] = res['default_twitter']['twitter:image'] = self.env['website'].image_url(self, 'image_1024') res['default_meta_description'] = self.description return res diff --git a/addons/website_slides/views/website_slides_templates_course.xml b/addons/website_slides/views/website_slides_templates_course.xml index 9fac350ac7169ab18cab045eacc61c361dde416d..6af0b555ce2dbfd003a0def0c8baa15580c45d17 100644 --- a/addons/website_slides/views/website_slides_templates_course.xml +++ b/addons/website_slides/views/website_slides_templates_course.xml @@ -120,7 +120,7 @@ <!-- ==== Header Left ==== --> <div class="col-12 col-md-4 col-lg-3"> <div class="d-flex align-items-start justify-content-around h-100"> - <div class="o_wslides_course_pict d-inline-block mb-2 mt-3 my-md-0" t-attf-style="background-image:url(/web/image/slide.channel/#{channel.id}/image_1024)" t-ignore="True"/> + <div class="o_wslides_course_pict d-inline-block mb-2 mt-3 my-md-0" t-attf-style="background-image: url(#{website.image_url(channel, 'image_1024')});" t-ignore="True"/> </div> </div> @@ -534,7 +534,7 @@ <!-- Featured lesson --> <div t-if="not search and not search_slide_type and slide_promoted" class="container py-1 mb-2"> <div class="card flex-column flex-lg-row"> - <t t-set="image_url" t-value="'/web/image/slide.slide/%s/image_1024' % slide_promoted.id"/> + <t t-set="image_url" t-value="website.image_url(slide_promoted, 'image_1024')"/> <a t-if="slide_promoted.is_preview or channel.is_member or is_slides_publisher" t-attf-href="/slides/slide/#{slug(slide_promoted)}#{query_string}" class="w-100 w-lg-50 flex-shrink-0 rounded"> @@ -609,7 +609,7 @@ <t t-set="can_access" t-value="slide.is_preview or channel.is_member or channel.can_publish"/> <t t-if="slide.image_1024"> - <t t-set="lesson_image" t-value="'/web/image/slide.slide/%s/image_1024' % slide.id"/> + <t t-set="lesson_image" t-value="website.image_url(slide, 'image_1024')"/> <a t-if="can_access" t-attf-href="/slides/slide/#{slug(slide)}#{query_string}" t-title="slide.name"> <div class="card-img-top border-bottom" t-attf-style="padding-top: 50%; background-image: url(#{lesson_image}); background-size: cover; background-position:center"/> </a> diff --git a/addons/website_slides/views/website_slides_templates_homepage.xml b/addons/website_slides/views/website_slides_templates_homepage.xml index 1ff6f0bc87f098910b97dfc26abedf5f3228e6d6..561ab5f2823901cd146010310f083168d5e89b04 100644 --- a/addons/website_slides/views/website_slides_templates_homepage.xml +++ b/addons/website_slides/views/website_slides_templates_homepage.xml @@ -297,7 +297,7 @@ <template id='course_card' name="Course Card"> <div t-attf-class="card w-100 o_wslides_course_card mb-4 #{'o_wslides_course_unpublished' if not channel.is_published else ''}"> - <t t-set="course_image" t-value="'/web/image/slide.channel/%s/image_1024' % channel.id"/> + <t t-set="course_image" t-value="website.image_url(channel, 'image_1024')"/> <a t-attf-href="/slides/#{slug(channel)}" t-title="channel.name"> <div t-if="channel.image_1024" class="card-img-top" t-attf-style="padding-top: 50%; background-image: url(#{course_image}); background-size: cover; background-position:center"/> <div t-else="" class="o_wslides_gradient card-img-top position-relative" style="padding-top: 50%; opacity: 0.8"> @@ -408,7 +408,7 @@ <div class="o_wslides_home_aside"> <div t-if="user.rank_id" class="d-flex align-items-center"> <span class="font-weight-bold text-muted mr-2">Current rank:</span> - <img t-attf-src="/web/image/gamification.karma.rank/#{user.rank_id.id}/image_64" height="16" alt="" class="mr-1"/> + <img t-att-src="website.image_url(user.rank_id, 'image_64')" height="16" alt="" class="mr-1"/> <a href="/profile/ranks_badges" t-field="user.rank_id"/> </div> <t t-set="next_rank_id" t-value="user._get_next_rank()"/> @@ -429,7 +429,7 @@ <div t-attf-class="d-flex mb-3 align-items-center #{'o_wslides_entry_muted' if not challenge_done else ''}"> <img class="mr-2" style="max-height: 36px;" - t-att-src="'/web/image/gamification.badge/%s/image_128' % challenge.reward_id.id" + t-att-src="website.image_url(challenge.reward_id, 'image_128')" t-att-alt="challenge.reward_id.name"/> <div class="flex-grow-1"> <b class="text_small_caps" t-esc="challenge.reward_id.name"/><br/> diff --git a/addons/website_slides/views/website_slides_templates_lesson.xml b/addons/website_slides/views/website_slides_templates_lesson.xml index 642e097aa645e60150e96f38cc1959c7c4037dfb..560bc59fa193e3013ffac9a9120fdaf0c806e101 100644 --- a/addons/website_slides/views/website_slides_templates_lesson.xml +++ b/addons/website_slides/views/website_slides_templates_lesson.xml @@ -89,7 +89,7 @@ <!-- Slide sub-template: display an item in a list of related slides (Related, Most Viewed, ...) --> <template id="slide_aside_card" name="Related Slide"> <a class="list-group-item list-group-item-action d-flex align-items-start px-2" t-att-href="'/slides/slide/%s' % (slug(aside_slide))"> - <t t-set="slide_image" t-value="'/web/image/slide.slide/%s/image_1024' % aside_slide.id"/> + <t t-set="slide_image" t-value="website.image_url(aside_slide, 'image_1024')"/> <div t-if="aside_slide.image_1024" class="flex-shrink-0 mr-1 border" t-attf-style="width: 20%; padding-top: 20%; background-image: url(#{slide_image}); background-size: cover; background-position:center"/> <div t-else="" class="o_wslides_gradient flex-shrink-0 mr-1" t-attf-style="width: 20%; padding-top: 20%;"/> @@ -234,7 +234,7 @@ </div> <div class="o_wslides_lesson_content_type"> <img t-if="slide.slide_type == 'infographic'" - t-attf-src="/web/image/slide.slide/#{slide.id}/image_1024" class="img-fluid" style="width:100%" t-att-alt="slide.name"/> + t-att-src="website.image_url(slide, 'image_1024')" class="img-fluid" style="width:100%" t-att-alt="slide.name"/> <div t-if="slide.slide_type in ('presentation', 'document')" class="embed-responsive embed-responsive-4by3 embed-responsive-item mb8" style="height: 600px;"> <t t-raw="slide.embed_code"/> </div> diff --git a/addons/website_slides/views/website_slides_templates_lesson_embed.xml b/addons/website_slides/views/website_slides_templates_lesson_embed.xml index d69ddef3215d69b9a0b972f699aa4a8afc9596a0..6713bda120ef0b3e7a410bf80ee06ef99a0a3675 100644 --- a/addons/website_slides/views/website_slides_templates_lesson_embed.xml +++ b/addons/website_slides/views/website_slides_templates_lesson_embed.xml @@ -58,7 +58,7 @@ <div class="col-6 col-md-4 col-lg-3 oe_slides_suggestion_media"> <div class="card mb-3"> <a t-att-href="suggest_slide.website_url" target="_new" class="card-img-top embed-responsive embed-responsive-16by9"> - <img t-attf-src="/web/image/slide.slide/#{suggest_slide.id}/image_1024" class="card-img-top embed-responsive-item" t-att-alt="suggest_slide.name"/> + <img t-att-src="website.image_url(suggest_slide, 'image_1024')" class="card-img-top embed-responsive-item" t-att-alt="suggest_slide.name"/> </a> <div class="card-body"> <h6 class="card-title"> @@ -80,14 +80,14 @@ <i class="fa fa-circle-o-notch fa-spin mr-2"/><b>Loading...</b> </div> <div class="toast-body p-0"> - <img class="img-fluid w-100" t-attf-src="/web/image/slide.slide/#{slide.id}/image_256"/> + <img class="img-fluid w-100" t-att-src="website.image_url(slide, 'image_256')"/> </div> </div> </div> <canvas id="PDFViewerCanvas" class="img-fluid w-100" style="display: none;"></canvas> </t> <t t-if="slide.slide_type == 'infographic'"> - <img t-attf-src="/web/image/slide.slide/#{slide.id}/image_1024" class="img-fluid" style="width: 100%" alt="Slide image"/> + <img t-att-src="website.image_url(slide, 'image_1024')" class="img-fluid" style="width: 100%" alt="Slide image"/> </t> </div> <!-- Fixed bottom navbar --> diff --git a/addons/website_slides/views/website_slides_templates_profile.xml b/addons/website_slides/views/website_slides_templates_profile.xml index e083fd724d6b49dba0f5f68c0e43f6cb9ebbf609..a6f62c1b4b1b93583f9f3ac88aabc4f7f65c26ed 100644 --- a/addons/website_slides/views/website_slides_templates_profile.xml +++ b/addons/website_slides/views/website_slides_templates_profile.xml @@ -39,7 +39,7 @@ <div class="card-body o_wprofile_slides_course_card_body p-0 d-flex" t-attf-onclick="location.href='/slides/#{slug(course.channel_id)}';"> - <div t-if="course.channel_id.image_1024" class="pl-5 pr-4 rounded-left" t-attf-style="background-image:url(/web/image/slide.channel/#{course.channel_id.id}/image_1024); background-size: cover; background-position: center"/> + <div t-if="course.channel_id.image_1024" class="pl-5 pr-4 rounded-left" t-attf-style="background-image: url(#{website.image_url(course.channel_id, 'image_1024')}); background-size: cover; background-position: center"/> <div t-else="" class="o_wslides_gradient pl-5 pr-4 rounded-left position-relative" style="opacity: 0.8"> <i class="fa fa-graduation-cap fa-fw mr-2 mt-3 position-absolute text-white-75" style="right:0; top: 0"/> </div> diff --git a/addons/website_slides_survey/views/website_profile.xml b/addons/website_slides_survey/views/website_profile.xml index dd80c485308ddbb4c876cd374a0c83d2e5a7a4a5..a2ab1fd05754eac179809a12661ed8633d6cdf81 100644 --- a/addons/website_slides_survey/views/website_profile.xml +++ b/addons/website_slides_survey/views/website_profile.xml @@ -17,7 +17,7 @@ <div class="col-12 col-lg-6" t-foreach="certificates" t-as="certificate"> <div class="card mb-2"> <div class="card-body o_wprofile_slides_course_card_body p-0 d-flex"> - <div class="pl-5 pr-4 rounded-left" t-attf-style="background-image:url(/web/image/slide.slide/#{certificate.slide_id.id}/image_128); background-position: center"/> + <div class="pl-5 pr-4 rounded-left" t-attf-style="background-image: url(#{website.image_url(certificate.slide_id, 'image_128')}); background-position: center"/> <div class="p-2 w-100"> <h5 class="mt-0 mb-1" t-esc="certificate.survey_id.title"/> <div t-if="user.id == uid">