Creating And Retrieving Open Graph Images
Last updated
Last updated
If the model preparation is done correctly, an OG Image will be created when a new record is created.
To manually trigger OG Image generation, you can call generateGraphify()
method on your model instance as below.
If your model does not have a slug then the generated images will not have any filename, therefore ther will only be one .png
image in your storage directory. To avoid this you will need to override the getGraphifyFileName
method in your model. Read for more information.
To retrieve a generated OG image, you can use the below method.
Sometimes things just do not go the way you want. So having a fallback OG Image when there is none available is a good thing to have. To define your fallback image, add the below method to your model and update the return value however you like.
You can add the generated OG images to your header using the below tags