Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
anchor-theme
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
tetras-libre
anchor-theme
Commits
0ce68790
Verified
Commit
0ce68790
authored
7 years ago
by
David Beniamine
Browse files
Options
Downloads
Patches
Plain Diff
Better image handling for articles
parent
baa6989d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
functions.php
+14
-5
14 additions, 5 deletions
functions.php
with
14 additions
and
5 deletions
functions.php
+
14
−
5
View file @
0ce68790
...
@@ -99,15 +99,24 @@ function total_articles() {
...
@@ -99,15 +99,24 @@ function total_articles() {
}
}
function
article_img_url
(
$slug
){
function
article_img_url
(
$slug
){
return
'/img/blog/'
.
$slug
.
'.png'
;
return
'/img/blog/'
.
$slug
;
}
}
function
article_has_img
(
$slug
){
function
article_img_ext
(
$slug
){
return
file_exists
(
'.'
.
article_img_url
(
$slug
));
$extensions
=
array
(
"png"
,
"jpg"
,
"jpeg"
,
"gif"
);
foreach
(
$extensions
as
$ext
){
foreach
(
array
(
$ext
,
strtoupper
(
$ext
))
as
$e
){
if
(
file_exists
(
'.'
.
article_img_url
(
$slug
)
.
'.'
.
$e
)){
return
$e
;
}
}
}
return
""
;
}
}
function
article_img
(
$slug
){
function
article_img
(
$slug
){
if
(
article_has_img
(
$slug
)){
$ext
=
article_img_ext
(
$slug
);
echo
'<img class="picture odd" src="'
.
article_img_url
(
$slug
)
.
'" />'
;
if
(
$ext
!=
""
){
echo
'<img class="odd" width="300px" src="'
.
article_img_url
(
$slug
)
.
'.'
.
$ext
.
'" />'
;
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment