Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pressr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Stephen D
Pressr
Commits
44196cd9
Commit
44196cd9
authored
5 years ago
by
Stephen D
Browse files
Options
Downloads
Patches
Plain Diff
Favicons
parent
baf65901
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/uploaders/image_uploader.rb
+20
-0
20 additions, 0 deletions
app/uploaders/image_uploader.rb
app/views/layouts/application.html.erb
+4
-0
4 additions, 0 deletions
app/views/layouts/application.html.erb
with
24 additions
and
0 deletions
app/uploaders/image_uploader.rb
+
20
−
0
View file @
44196cd9
...
...
@@ -28,6 +28,16 @@ class ImageUploader < CarrierWave::Uploader::Base
# # do something
# end
def
efficient_conversion
(
width
,
height
)
manipulate!
do
|
img
|
img
.
format
(
"png"
)
do
|
c
|
c
.
resize
"
#{
width
}
x
#{
height
}
>"
c
.
resize
"
#{
width
}
x
#{
height
}
<"
end
img
end
end
#Max size
process
resize_to_limit:
[
2000
,
2000
]
...
...
@@ -40,6 +50,16 @@ class ImageUploader < CarrierWave::Uploader::Base
process
resize_to_limit:
[
300
,
300
]
end
version
:icon
do
process
efficient_conversion:
[
256
,
256
]
def
png_url
return
nil
if
self
.
url
.
nil?
#mega hack
self
.
url
[
0
..-
4
]
+
"png"
end
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def
extension_whitelist
...
...
This diff is collapsed.
Click to expand it.
app/views/layouts/application.html.erb
+
4
−
0
View file @
44196cd9
...
...
@@ -11,6 +11,10 @@
<%=
javascript_pack_tag
'application'
,
'data-turbolinks-track'
:
'reload'
%>
<%=
javascript_include_tag
'application'
,
'data-turbolinks-track'
:
'reload'
%>
<%
unless
current_blog
.
nil?
||
current_blog
.
logo
.
icon
.
url
.
nil?
%>
<%=
favicon_link_tag
current_blog
.
logo
.
icon
.
png_url
%>
<%
end
%>
<%=
yield
:head
%>
</head>
...
...
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