项目作者: placidapp

项目描述 :
✨ Automatic image creation from templates
高级语言: PHP
项目地址: git://github.com/placidapp/placid-laravel.git
创建时间: 2019-08-14T11:06:19Z
项目社区:https://github.com/placidapp/placid-laravel

开源协议:MIT License

下载


Placid for Laravel - Automatic image creation from templates

Placid for Laravel

Latest Version
Total Downloads
MadeWithLaravel.com shield

This package enables you to automatically create images from Placid templates. You can use the REST API or the URL API to create placid.app embed links with your variables to dynamically set the image content.

About Placid

To use this package, you will need a Placid account, where you can add, design and edit image templates.

It is a service that automatically creates share images for your content: Open Graph images (og:images), Twitter Card images and Pinterest images. This saves you hours to make your content shareable after publishing. We offer a bunch of nice preset designs you can use out of the box as well.

More than share images: With our editor you have full control over your templates, so you can use it for other types of images to add to your content as well (like teasers or blog graphics).

Create a placid.app image URL

  1. $templateId = "qsraj";
  2. $template = Placid::template($templateId)
  3. $template
  4. ->elementText($title)
  5. ->text("I am a dynamic image");
  6. $imageURL = $template->toPlacidUrl(); // - https://placid.app/u/qsraj?title=I%20am%20a%20dynamic%20Image%21

Dynamically created image with Placid

Generate an Image

Using the image() function on the template object will result in returning a GeneratedImage Object. When the image has been created, the webhook defined in your config will be called!

  1. $image = $template->image();

image(true) will wait for the image to being finished:

  1. $image = $template->image(true); // - https://placid.app/u/qsraj?title=I%20am%20a%20dynamic%20Image%21

Fields

You can add different elements onto your template that can be changed and filled dynamically.

Text field

  1. $template
  2. ->elementText("text") // - Layer name in your template
  3. ->text("This is the text")
  4. ->color('#ff0022'); // - Text color as hex-code

PLEASE NOTE: The text color can only be changed when you use the image() function to generate an image, not if you use the URL API.

Picture field

  1. $template
  2. ->elementPicture('picture') // - Layer name in your template
  3. ->imageFromUrl(
  4. "https://madewithvuejs.com/mandant/madewithvuejs/images/logo.png" // - image source
  5. );
  6. $template
  7. ->elementPicture('picture') // - Layer name in your template
  8. ->imageFromWebsite("https://madewithvuejs.com"); // - URL of a page to screenshot

Browserframe field

  1. $template
  2. ->elementBrowserframe('browserframe') // - Layer name in your template
  3. ->imageFromUrl(
  4. "https://madewithvuejs.com/mandant/madewithvuejs/images/logo.png" // - image source
  5. )
  6. ->url("madewithvuejs.com"); // - URL that will be displayed in the browserframe's address bar
  7. $template
  8. ->elementBrowserframe('browserframe') // - Layer name in your template
  9. ->imageFromWebsite("https://madewithvuejs.com") // - URL of a page to screenshot
  10. ->url("madewithvuejs.com"); // - URL that will be displayed in the browserframe's address bar

Rectangle field

  1. $template
  2. ->elementRectangle('rectangle') // - Layer name in your template
  3. ->backgroundColor("#000000"); // - Background color as hex-code

PLEASE NOTE: The background color can only be changed when you use the image() function to generate an image, not if you use the URL API.

Installation

You can install this package via composer using this command:

  1. composer require placidapp/placid-laravel

The package will automatically register itself.

You can publish the config-file with:

  1. php artisan vendor:publish --provider="Placid\Laravel\PlacidLaravelServiceProvider" --tag="config"

These are the contents of the published config file:

  1. return [
  2. /**
  3. * Placid API Token
  4. */
  5. 'api-token' => null,
  6. /**
  7. * Placid Success Webhook
  8. *
  9. * Will be called when your created image is ready
  10. */
  11. 'webhook_url' => null
  12. ];

License

The MIT License (MIT). Please see License File for more information.