{"id":17275061,"url":"https://github.com/hirasso/focal-point-picker","last_synced_at":"2025-04-14T09:11:54.802Z","repository":{"id":245867375,"uuid":"819404742","full_name":"hirasso/focal-point-picker","owner":"hirasso","description":"Zero-dependency custom focal point picker for your WordPress images 🎯","archived":false,"fork":false,"pushed_at":"2025-02-14T13:29:49.000Z","size":111,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-14T09:11:36.974Z","etag":null,"topics":["focal-point","wordpress"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hirasso.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-24T12:42:58.000Z","updated_at":"2025-04-01T11:21:37.000Z","dependencies_parsed_at":"2025-01-17T12:25:53.508Z","dependency_job_id":"f9f7f64b-0043-4c62-8a95-beed7228c09a","html_url":"https://github.com/hirasso/focal-point-picker","commit_stats":null,"previous_names":["hirasso/wp-focalpoint","hirasso/focal-point-picker"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirasso%2Ffocal-point-picker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirasso%2Ffocal-point-picker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirasso%2Ffocal-point-picker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirasso%2Ffocal-point-picker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hirasso","download_url":"https://codeload.github.com/hirasso/focal-point-picker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248852182,"owners_count":21171842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["focal-point","wordpress"],"created_at":"2024-10-15T08:55:20.256Z","updated_at":"2025-04-14T09:11:54.777Z","avatar_url":"https://github.com/hirasso.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# focal-point-picker\n\nZero-dependency [focal point](\u003c[url](https://en.wikipedia.org/wiki/Focus_(optics))\u003e) picker for your WordPress website. Works with older installs, too.\n\n![CleanShot 2024-06-24 at 15 18 15@2x](https://github.com/hirasso/focal-point-picker/assets/869813/3717cedb-d1db-4192-b24d-9997e48432c9)\n\n## Installation\n\n### Via Composer (recommended):\n\n1. Install the plugin:\n\n```shell\ncomposer require hirasso/focal-point-picker\n```\n\n1. Activate the plugin manually or using WP CLI:\n\n```shell\nwp plugin activate hirasso/focal-point-picker\n```\n\n### Manually:\n\n1. Download and extract the plugin\n2. Copy the `focal-point-picker` folder into your `wp-content/plugins` folder\n3. Activate the plugin via the plugins admin page – Done!\n4. Handle updates via [afragen/git-updater](https://github.com/afragen/git-updater)\n\n## Data structure\n\nYou can retrieve the focal point for an image like this:\n\n```php\n$focalPoint = fcp_get_focalpoint($imageID);\nvar_dump($focalPoint);\n```\n\n### Output:\n\n```\nobject(FocalPointPicker\\FocalPoint)#2796 (4) {\n  [\"left\"]=\u003e\n  float(0.5)\n  [\"top\"]=\u003e\n  float(0.5)\n  [\"leftPercent\"]=\u003e\n  float(50)\n  [\"topPercent\"]=\u003e\n  float(50)\n  [\"x\"]=\u003e\n  float(0.5)\n  [\"y\"]=\u003e\n  float(0.5)\n  [\"xPercent\"]=\u003e\n  float(50)\n  [\"yPercent\"]=\u003e\n  float(50)\n}\n```\n\n## Usage in your templates\n\n### Object Position\n\n```php\n\u003c?php\n\n$imageID = 1234;\n$imageSRC = wp_get_attachment_image_src($imageID)['large'];\n$focus = fcp_get_focalpoint($imageID);\n\n?\u003e\n\n\u003cstyle\u003e\n#my-image {\n  height: 300px;\n  width: 600px;\n  position: relative;\n}\n#my-image img {\n  display: block;\n  width: 100%;\n  height: 100%;\n  object-fit: cover;\n}\n\u003c/style\u003e\n\n\u003cdiv id=\"my-image\"\u003e\n  \u003cimg\n    src=\"\u003c?= $imageSRC[0] ?\u003e\"\n    style=\"object-position: \u003c?= $focus-\u003eleftPercent ?? 50 ?\u003e% \u003c?= $focus-\u003etopPercent ?? 50 ?\u003e%;\"\u003e\n\u003c/div\u003e\n```\n\n### Background Position\n\n```php\n\u003c?php\n\n$imageID = 1234;\n$imageSRC = wp_get_attachment_image_src($imageID)['large'];\n$focus = fcp_get_focalpoint($imageID);\n\n?\u003e\n\n\u003cstyle\u003e\n#my-image {\n  background-image: url('\u003c?php echo $imageSRC[0]; ?\u003e');\n  background-size: cover;\n  height: 300px;\n  width: 600px;\n}\n\u003c/style\u003e\n\n\u003cdiv\n  id=\"my-image\"\n  style=\"background-position: \u003c?= $focus-\u003eleftPercent ?? 50 ?\u003e% \u003c?= $focus-\u003etopPercent ?? 50 ?\u003e%;\"\u003e\n\u003c/div\u003e\n```\n\n### Using `wp_get_attachment_image`\n\nIf you are making use of the WordPress function [`wp_get_attachment_image()`](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/), the plugin will automatically inject a class `focal-point-image` and two custom css properties for you to use:\n\n```diff\n\u003cimg\n  width=\"150\"\n  height=\"150\"\n  src=\"http://example.com/wp-content/uploads/bear-150x150.png\"\n+ class=\"attachment-thumbnail size-thumbnail focal-point-image\"\n  alt=\"\"\n  decoding=\"async\"\n  loading=\"lazy\"\n+ style=\"--focal-point-left: 0.46; --focal-point-top: 0.2\"\n\u003e\n```\n\nYou can use that like this, for example:\n\n```css\n.focal-point-image {\n  aspect-ratio: 16/7; /** or whatever you like */\n  height: auto;\n  object-fit: cover;\n  object-position:\n    calc(var(--focal-point-left, 0.5) * 100%)\n    calc(var(--focal-point-top, 0.5) * 100%);\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhirasso%2Ffocal-point-picker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhirasso%2Ffocal-point-picker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhirasso%2Ffocal-point-picker/lists"}