diff --git a/.editorconfig b/.editorconfig
old mode 100755
new mode 100644
diff --git a/LICENSE.md b/LICENSE.md
old mode 100755
new mode 100644
diff --git a/_config.php b/_config.php
index 31e7d5b..a4abe2d 100644
--- a/_config.php
+++ b/_config.php
@@ -1,3 +1,2 @@
addFieldToTab('Root.Main', ToggleCompositeField::create('OpenGraph', 'Open Graph',
- [
- LiteralField::create('', '
Open Graph Information  . 'open-graph-meta/images/opengraph.png)
'),
- TextField::create('OGTitle', '')
- ->setAttribute('placeholder', 'e.g My Website')
- ->setRightTitle('Page title goes here, automatically defaults to the page title'),
- DropdownField::create('OGContent', 'Content Type', $this->owner->dbObject('OGContent')->enumValues())
- ->setRightTitle('Will default to website (the most common open graph object type'),
- TextareaField::create('OGDescription', '')
- ->setRightTitle('Page description goes here, automatically defaults to the content summary'),
- UploadField::create('OGImage', 'Open Graph Image')
- ->setDescription('Ideal size: 1200px * 630px')
- ]
- ));
+ $imageUrl = ModuleResourceLoader::singleton()
+ ->resolveUrl('toastnz/open-graph-meta:client/images/opengraph.png');
+
+ $headerHtml = sprintf(
+ ' Open Graph Information 
',
+ $imageUrl
+ );
+
+ $fields->addFieldToTab(
+ 'Root.Main',
+ ToggleCompositeField::create(
+ 'OpenGraph',
+ 'Open Graph',
+ [
+ LiteralField::create('', $headerHtml),
+ TextField::create('OGTitle', '')
+ ->setAttribute('placeholder', 'e.g My Website')
+ ->setRightTitle('Page title goes here, automatically defaults to the page title'),
+ DropdownField::create(
+ 'OGContent',
+ 'Content Type',
+ $this->owner->dbObject('OGContent')->enumValues()
+ )->setRightTitle('Will default to website (the most common open graph object type'),
+ TextareaField::create('OGDescription', '')
+ ->setRightTitle(
+ 'Page description goes here, automatically defaults to the content summary'
+ ),
+ UploadField::create('OGImage', 'Open Graph Image')
+ ->setDescription('Ideal size: 1200px * 630px')
+ ]
+ )
+ );
}
public function FirstImage()
{
$pattern = ' /
]+ src[\\s = \'"]';
$pattern .= '+([^"\'>\\s]+)/is';
+
if (preg_match_all($pattern, $this->owner->Content, $match)) {
$imageLink = preg_replace('/_resampled\/resizedimage[0-9]*-/', '', $match[1][0]);
return (string)$imageLink;
@@ -129,7 +150,10 @@ public function MetaTags(&$tags)
if (trim($this->owner->OGDescription)) {
$tags .= sprintf('', $this->owner->OGDescription) . "\n";
} elseif ($this->owner->Content) {
- $tags .= sprintf('', $this->owner->dbObject('Content')->FirstParagraph()) . "\n";
+ $tags .= sprintf(
+ '',
+ $this->owner->dbObject('Content')->FirstParagraph()
+ ) . "\n";
}
// Image
diff --git a/code/extensions/OpenGraphSiteConfigExtension.php b/src/Extensions/OpenGraphSiteConfigExtension.php
similarity index 96%
rename from code/extensions/OpenGraphSiteConfigExtension.php
rename to src/Extensions/OpenGraphSiteConfigExtension.php
index 06dc2dd..797ee1a 100644
--- a/code/extensions/OpenGraphSiteConfigExtension.php
+++ b/src/Extensions/OpenGraphSiteConfigExtension.php
@@ -1,5 +1,7 @@
Title . $this->eol;
foreach ($this->fields_to_update as $fieldName) {
- $oldData = DB::query("SELECT {$fieldName} FROM Page WHERE ID = {$id}")->column($fieldName);
+ $oldData = DB::query("SELECT {$fieldName} FROM Page WHERE ID = {$id}")
+ ->column($fieldName);
- $newData = DB::query("SELECT {$fieldName} FROM SiteTree WHERE ID = {$id}")->column($fieldName);
+ $newData = DB::query("SELECT {$fieldName} FROM SiteTree WHERE ID = {$id}")
+ ->column($fieldName);
if (!empty($oldData)) {
// If new data has been saved and we don't want to overwrite, exit the loop
if (!empty($newData) && !$overwrite) {
continue;
}
+
$data = Convert::raw2sql($oldData[0]);
+
DB::query("UPDATE SiteTree SET {$fieldName} = '{$data}' WHERE ID = {$id}");
DB::query("UPDATE SiteTree_Live SET {$fieldName} = '{$data}' WHERE ID = {$id}");
} else {