Jump to content

Share image in database article


Owdy
 Share

Recommended Posts

If i upload Record Image, its used also in social media share image:

<meta property="og:image" content="https://******net/uploads/monthly_2019_12/12.jpg.cd2592c7bc930062a.jpg">

Is there way to make field Record Image hidden, so it would not show in page, but be used as share image? Also, i sometimes wanna show it, sometimes not. Show when i create article, it would be setting  as hidden/visible. Possible?

Link to comment
Share on other sites

Well, it would need template customization. You can add a custom YesNo field to the article database and then wrap the image output with a condition checking that field. 
I have a database where I do the same for the showing or hiding the record author. 

{{if $record->field_123}}
//Output something
{{endif}}

“123” is the field ID of the checkbox field. 

P.S. Using the record image as sharer image is defined in the code and so it works independently from actually showing the image on the page. 

Link to comment
Share on other sites

 

{{if $record->record_image}}
		<div class="cCmsRecord_image">
              	
                {{if $record->field_kuva44}}
	       <img class="ipsImage" src="{file="$record->_record_image_thumb" extension="cms_Records"}">
                {{endif}}
          
          <div style="margin-top:5px">{$record->customFieldDisplayByKey('kuvateksti')|raw}</div>
		</div>
{{endif}}

Tryed this. It hides image even if selected YES. kuva44 is key

edit: typo, IT WORKS!!! Thanks 🙂

 

Edited by Owdy
Link to comment
Share on other sites

Seems in old articles, ill have to edit and toggle NO/YES and save, then it works. Yes is default, but now all images are hidden from old articles

How do i set YES to all old articles? Some sql quoery?

Edited by Owdy
Link to comment
Share on other sites

ALTER TABLE `ipb_cms_custom_database_8` CHANGE `field_22` `field_22` INT(10) NULL DEFAULT '1';

This? edit: no...

This?

UPDATE ipb_cms_custom_database_8 SET field_22 = '1';

 

@opentype heeelp 🙂

 

edit3. it WORKED! Thank you! 😍

Edited by Owdy
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...