Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Camo Image Proxy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WP Plugins
Camo Image Proxy
Merge requests
!6
add linting
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
add linting
add/lint
into
master
Overview
0
Commits
20
Pipelines
1
Changes
3
Merged
Erick Hitter
requested to merge
add/lint
into
master
6 years ago
Overview
0
Commits
20
Pipelines
1
Changes
3
Expand
0
0
Merge request reports
Viewing commit
e6c5b324
Prev
Next
Show latest version
3 files
+
51
−
3
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
e6c5b324
Camouflage attachment URLs
· e6c5b324
Erick Hitter
authored
7 years ago
inc/class-rewrite-urls.php
+
38
−
0
Options
<?php
/**
* Force Core's image functions to use Camo
*
* @package Camo_Image_Proxy
*/
namespace
Camo_Image_Proxy
;
/**
* Class Rewrite_URLs
*/
class
Rewrite_URLs
{
use
Singleton
;
/**
* Hooks
*/
public
function
setup
()
{
add_filter
(
'wp_get_attachment_image_src'
,
[
$this
,
'encode_image'
]
);
}
/**
* Camouflage attachment URL
*
* @param array $image Image data.
* @return array
*/
public
function
encode_image
(
array
$image
)
:
array
{
$url
=
URL
::
instance
()
->
encode
(
$image
[
0
]
);
if
(
is_string
(
$url
)
)
{
$image
[
0
]
=
$url
;
}
return
$image
;
}
}
Loading